#include <bits/stdc++.h>
#define MOD 1000000007
#define MOD2 998244353
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loopr(i,a,b) for(ll i=a;i>=b;i--)
#define loops(i,a,b,step) for(ll i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(ll i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define ld long double
using namespace std;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    test{
        ll n;
        cin>>n;
        ll A[n];
        loop(i,0,n){
            cin>>A[i];
        }
        ll ans = inf;
        ll sum = 0;
        loop(i,0,n){
            sum+=A[i];
        }
        loopr(len, n, 1){
            if(sum%len!=0){
                continue;
            }
            ll goal = sum/len;
            ll flag = 1;
            for(ll i=0;i<n;){
                ll sum = 0;
                while(i<n && sum<goal){
                    sum+=A[i++];
                }
                if(sum!=goal){
                    flag = 0;
                    break;
                }
            }
            if(flag){
                ans = min(ans, n-len);
            }
        }
        cout<<ans<<endl;
    }   
    return 0;
}