#include<math.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define deg(x) cout<<#x<<" "<< x <<endl;
#define mod 1000000007
#define ll long long 
#define print(x) cout<<x<<endl;
#define input(x) cin>>x
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false)
bool check(int a[],int sum,int n,int k){
int count=0;
int ksum=0;
for(int i=0;i<n;i++){
    ksum+=a[i];
    if(ksum==sum){
        ksum=0;
        count++;
    }
}

if(k==count)
return true;

return false;
}


int main()
{
    int t;
    cin>>t;
    while (t>0)
    {
        int n;
        cin>>n;
        int i,j;
        int a[n];
        ll sum=0;
        for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        }
       int ans=INT32_MAX;
        for(i=0;i<n;i++){
           if(sum%(n-i)==0){
               int x=sum/(n-i);
            if(check(a,x,n,n-i)==true){
                ans=min(i,ans);
            }
           }
        }
        print(ans);

        t--;
    }
    

}

