#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    int sum=0;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int fl=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
        {
            
        }
        else
        {
            fl=1;
        }
    }
   // int sum=0;
    if(fl==0)
    {
        cout<<0<<"\n";
    }
    else
    {
        int p=n;
        for(int i=n-1;i>=1;i--)
        {
            if(sum%i==0)
            {
                int k=sum/i;
                int sum1=0;
                fl=0;
                for(int j=0;j<n;j++)
                {
                    sum1+=a[j];
                  //  cout<<sum1<<" "<<k<<"\n";
                    if(sum1>k)
                    {
                        fl=1;
                        break;
                    }
                    else if(sum1<k)
                    {
                        continue;
                    }
                    else
                    {
                        sum1=0;
                    }
                }
                if(fl==0)
                {
                  //  cout<<i<<" ";
                    cout<<(n-i)<<"\n";
                    return;
                }
            }
            
        }
        cout<<n-1<<"\n";
            return;
    }
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
       // cout<<"\n";
    }
}