#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
#include<stack>
#include<queue>
using namespace std;
#define pb push_back
#define ff(i,a,b) for(int i=a;i<b;++i)
#define ffr(i,b,a) for(int i=b;i>=a;--i)
#define fflr(i,b,a) for(long long i=b;i>=a;--i)
#define ffl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int md = 1000000007;
#define pi 3.141592653589793238462643383279


int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    
 	int tt{},T{};
 	cin>>tt;T=tt;
    //tt=1;
 	while(tt--){
        //cout<<"------------- #"<<T-tt<<endl;
        ll n{},m{},ans{},k{},a{},b{},c{},f{};
        //string str,sa;
        
        cin>>n;
        vecl v(n);
        ffl(i,0,n)cin>>v[i];
        
        set<ll> s(all(v));
        if(s.size()==1){
            cout<<"0\n";
            continue;
        }
        
//        ff(i,1,n+1){
//            s[i]=s[i-1]+v[i];
//        }
        ans=n-1;
        a=0;
        ffl(i,0,n-1){
            a+=v[i];
            k=i;
            c=i;
            //cout<<i<<"m"<<*max_element(v.begin()+i+1,v.end())<<" <";
            if(*max_element(v.begin()+i+1,v.end())<=a){
                b=0;
                f=0;
                int j=i+1;
                //k=1;
                while(j<n){
                    if(b+v[j]<a){
                        b+=v[j];
                        ++j;
                    }else if(b+v[j]==a){
                        b=0;
                        k+=j-c-1;
                        c=j;
                        ++j;
                        if(j==n)f=1;
                    }else{
                        break;
                    }
                }
                //cout<<i<<":"<<k<<" = ";
                if(f){
                    ans=min(ans,k);
                }
            }
        }
        cout<<ans<<"\n";
        
        
    }
    
    // SEE THE TUTORIAL ALMOST NEVER //
	return 0;
}