/*          _/_/_/_/_/_/  _/_/_/_/_/  _/_/_/_/_/  _/_/_/_/_/  _/_/_/_/_/  _/   _/         _/      _/  _/          _/          _/      _/  _/      _/  _/  _/        _/      _/  _/_/_/      _/_/_/      _/_/_/_/_/  _/_/_/_/_/  _/_/       _/      _/  _/          _/          _/          _/      _/  _/  _/    _/_/_/_/_/_/  _/_/_/_/_/  _/_/_/_/_/  _/          _/      _/  _/    _/   */      #include<bits/stdc++.h>   #include<math.h>   #define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   #define int             long long   #define test            int t; cin>>t; while(t--)   #define vi              vector<int> v;   #define pb              push_back   #define input(arr)      int n; cin>>n; int arr[n]; for(int i=0; i<n; i++) {cin>>arr[i];}   #define f(n)            for(int i=0; i<n; i++)   #define OK              if(ok){cout<< YES <<endl;} else{cout<< NO <<endl;}   #define Ok              if(ok){cout<< Yes <<endl;} else{cout<< No <<endl;}   #define mod             1000000007   #define endl   n    using namespace std;   //-----------------------------------------------------------------------------       // to check prime number IN O(sqrt(n))   //bool isPrime(int);   //   //// to get divisors of a number IN O(sqrt(n))   //vector<int> divisors(int);   //   //// to find power using mod using Binary Exponential in TC O(logn)   //int power(int, int, int);   //   //// ternary search to find x in sorted array arr   //int ts(int, int, int, int);   //   //// to find frequencies of a substring in a string or to find all positions of all substrings   //vector<int> count_freq(string ,string);   //   ////to check palindrome   //bool palindrome(int, int);   //   #ifndef ONLINE_JUDGE   // if (fopen( input.txt ,  r ))   // {   //  freopen( input.txt ,  r , stdin);   //  freopen( output.txt ,  w , stdout);   // }   // #endif       //*************************************************************************************************      vector<int> printDivisors(int n, int temp)    {      vector<int> vec;       // Note that this loop runs till square root        for (int i=1; i<=sqrt(n); i++)        {            if (n%i == 0)            {                // If divisors are equal, print only one                if (n/i == i)                {                 if(i >= temp)                   vec.pb(i);               }                     else // Otherwise print both                {                 if(i >= temp)                   vec.pb(i);                 if((n/i) >= temp)                   vec.pb(n/i);               }            }        }        return vec;   }      int32_t main()   {     IOS     #ifndef ONLINE_JUDGE    if (fopen( input.txt ,  r ))    {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);    }    #endif        test     {       int n;       cin >> n;       int arr[n];       int temp = 0;       int sum = 0;       f(n)       {         cin >> arr[i];         sum += arr[i];         temp = max(temp, arr[i]);       }          vector<int> v = printDivisors(sum, temp);       sort(v.begin(), v.end());          int ans = 0;       int j=0, add=0;       int t1 = v[j];          for(int i=0; i<n; i++)       {         if(arr[i] != t1)         {           add += arr[i];                                ans++;           if(add > t1)           {             ans = 0;             add = 0;             i = -1;             ++j;             t1 = v[j];           }           else if(add == t1)           {             ans--;             add = 0;           }         }         else if(add > 0)         {           add = 0;           ans = 0;           i = -1;           ++j;           t1 = v[j];         }       }       cout << ans << endl;     }     return 0;   }         //******************************************************************************       //getchar() - uses for no extra comments in output section   //toupper() - converts a string in uppercase   //tolower()   //lower_bound((a, a+n, m)-a) - when you have to find total number of small values to m b/w range of a to a+n   //   or finds the lower position of num. eg 10 20 30 30 30 40 50 num=30, ans = 2;   //upper_bound - work as lower_bound but finds the upper position. eg 10 20 30 30 30 40 50 num=30, ans = 5;    //shift+f6+enter - to change a word everywhere   //stringstream - to find number of words in a string or to find frequency of words   //s.substr(1, 3) - geeks - eek   //*max_element(v+2, v+4) - to find max element in an array   //*min_element   //__gcd(2, 10) - to find greatest common devisor, doesn t support float or double   //count(a, a+n, k) - to find frequency of k or frequency of a char in string in an array or in vector   //s =  aaaaa , a[2]++, s = aabaa   //compare() - to campare to string s size   //__builtin_popcountll(n) - number of bit 1 in n   //__builtin_ctzll(n) - number of bit 0 after last 1   //cout<<fixed()<<setprecision(k)<<endl;   //log(n) - to find digits in binary repersatation, returns float value   //floor(1.3) - 3, floor(-1.2) - -2       //******************************************************************************                   //// to check prime number   //bool isPrime(int n)  //IN  O(sqrt(n))   //{   //    if(n<=1) return false;   //    for(int i=2;i*i<=n;i++)   //        if(n%i==0)   //            return false;   //   //    return true;   //}   //   //// to get divisors of a number. Recall - it s not i sorted order   //// vector<int> v = divisors(n); function call   //vector<int> divisors(int n){    //IN  O(sqrt(n))   //   //    vector<int> v;   //    for(int i=1;i*i<=n;i++)   //    {   //        if(n%i==0)   //        {   //            v.pb(i);   //            if((n/i)!=i)   //            v.pb(n/i);   //        }   //    }   //    return v;   //}   //   //// to find power using mod   //int power(int a, int n, int m)  // using Binary Exponential in TC O(logn)   //{   //    int res=1;   //    while(n)   //    {   //        if(n%2)   //        res=(res*a)%m ,n--;   //        else   //        a=(a*a)%m ,n/=2;   //    }   //    return res;   //}   //   //// ternary search to find x in sorted array arr   //int ts(int arr[],int l,int r,int x)   //{   //   //    while(l<=r)   //    {   //        int mid1= l+(r-l)/3;   //        int mid2= r -(r-l)/3;   //        if(arr[mid1]==x || arr[mid2]==x)   //            return 1;   //        if(x<arr[mid1])   //            r=mid1-1;   //        else if(x>arr[mid2])   //            l=mid2+1;   //        else   //        {   //            l=mid1+1;   //            r=mid2-1;   //        }   //    }   //    return 0;   //}   //   //// to find frequencies of a substring in a string or to find all positions of all substrings   //// vector<int> v = count_freq(s1 ,s2); function calling   //// position storing is 0 based indexing add 1 if required 1 based indexing.   ////This code is used to count the frequency of particular substring in a given string using the found function   //vector<int> count_freq(string &str ,string &substr)   //{   // vector<int>pos;   // size_t found = str.find(substr,0);   // while(found!=string::npos)   // {   //  pos.pb(found);   //  found=str.find(substr,found+1);   //    }   //    return pos;   //}   //   //   //bool palindrome(int arr[], int n)   //{   //    int flag = 0;   //    for (int i = 0; i <= n / 2 && n != 0; i++) {   //        if (arr[i] != arr[n - i - 1]) {   //            flag = 1;   //            break;   //        }   //    }   //    if (flag == 1)   //        return true;   //    else   //        return false;   //}