
#include <bits/stdc++.h>
using namespace std;
bool isPoss(vector<int> v,int tar,int sum){
    int ch= sum/tar;
    int n = v.size();
    int sm=0,ct=0;
    for(int i=0;i<n;i++){
        if(sm==tar){
            // cout<<i<<"**"<<endl;
            ct++;
            sm=v[i];
        }else{
            sm = sm + v[i];
        }
    }
    // cout<<sm<<endl;
    if(sm==tar){
        ct++;
    }
    // cout<<ct<<endl<<endl<<endl;
    if(ch==ct) return true;

    return false;

}

int main(){
    ios_base::sync_with_stdio(false);//disconnect c with c++(false)
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("output.txt","w",stdout);
        freopen("input.txt","r",stdin);
    #endif
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> v(n);
         int sum=0;
       int mx=INT_MIN;
        for(auto &it:v){
            cin>>it;
            sum +=it;
            mx  = max(mx,it);
        } 
        int i;
        for(i=mx;i<=sum;i++){
            if(sum%i==0){
                // cout<<sum<<" "<<i<<endl;
                bool ch = isPoss(v,i,sum);
                if(ch==true){
                    cout<<n-sum/i<<endl;
                    break;
                }
            }
        }
      
       

    }
    return 0;
}