#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ppp pair<pii,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define CL(x) memset(x,0,sizeof(x))
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x.size())
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
#define DI(x) (int)(x-'0')
#define LL_MAX (1LL<<60)
#define DB 0
#define DBG(x) if(DB)cout << #x << " : " << x << '\n'
#define PRALL(v) if(DB)for(auto it : v)cout<<v<<' '; NL;
#define NL cout<<'\n';
#define FND(S,x) (S.find(x)!=S.end())
#define bit(x,y) (!!(x&(1<<y)))
typedef long long ll;
typedef long double ld;

#define MXN 3005
int T, N, A[MXN];
int S;

int ans;
void chk(int x)
{
    int cur=0;
    int op=0;
    FOR(i,1,N)
    {
        cur+=A[i];
        if( cur==x )cur=0;
        else if( cur>x )
        {
            return;
        }
        else
        {
            op++;
        }
    }
    ans=min(op,ans);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>T;
    FOR(t,1,T)
    {
        cin>>N;
        S=0;
        FOR(i,1,N)
        {
            cin>>A[i];
            S+=A[i];
        }
        ans=N-1;
        for( int x=1; x*x<=S; x++ )
        {
            if(S%x!=0)continue;
            chk(x);
            chk(S/x);
        }
        cout<<ans<<'\n';
    }

    return 0;
}
