#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops"
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define MOD 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll		// this is 1e18 long long 
#define np next_permutation
#define PI acos(-1)
#define DEB(x) cout<<#x<<" "<<x<<endl;
#define rotate_left(vec,amt) rotate(vec.begin(),vec.begin()+amt,vec.end());
#define rotate_right(vec,amt) rotate(vec.begin(),vec.begin()+vec.size()-amt,vec.end());
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x,0,sizeof(x))
using namespace std;

int main()
{
    speed;
    ll t=1;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n],sum=0;
        rep(i,0,n)
        {
            cin>>a[i];
            sum+=a[i];
        }
        set<ll>s;
        ll ans=n-1;
        per(i,1,n+1)
        {
            if(sum%i!=0)
            continue;

            ll also=sum/i;
            ll temp=0,tmp=0;
            bool flag=true;
            s.clear();
            rep(j,0,n)
            {
                while(j<n && temp+a[j]<=also)
                {
                    temp+=a[j];
                    j++;
                }
                if(temp!=also)
                {
                    flag=false;
                    break;
                }
                tmp++,temp=0,j--;
            }
            if(flag)
            {
                ans=n-tmp;
                break;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
/*
test cases
4
5
3 1 6 6 2
4
1 2 2 1
3
2 2 2
4
6 3 2 1

*/