#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<ctime>
#define iss ios::sync_with_stdio(false)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int mod=1e9+7;
const int MAXN=2e5+5;
const int inf=0x3f3f3f3f;
int a[MAXN];
int sum[MAXN];
int main()
{
//==========================================
#ifndef ONLINE_JUDGE
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
#endif
//==========================================
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            sum[i]=sum[i-1]+a[i];
        }
        int ans=1e9;
        for(int i=1;i<=n;i++)
        {
            int pre=sum[i];
            int cnt=1;
            int res=0;
            for(int j=i+1;j<=n;j++)
            {
                res+=a[j];
                if(res==pre)
                {
                    cnt++;
                    res=0;
                }
                else if(res>pre)
                {
                    cnt=-1;
                    break;
                }
            }
            if(cnt==-1||(res<pre&&res!=0)) continue;
            else ans=min(ans,n-cnt);
        }
        cout<<ans<<endl;
    }
}
   	 		  	 			 		      		   			