#include<iostream>
#include<bits/stdc++.h>
#include<string>

using namespace std;



int main()
{

int t;
cin>>t;
for(int xxx =1;xxx<=t;xxx++)
{

int n,m=-2147483648;
cin>>n;
int i,sum=0,x,ans=0,b[n];
vector<int> a;
map<int,int> mp;
for(i=0;i<n;i++)
{
    cin>>x;
    a.push_back(x);
    b[i]=x;
    if(a[i]>m)
        m= a[i];
        sum=sum+a[i];
}
while(sum% m !=0)
{
   m++;
}
mp.insert({m,0});
while(mp[m] != a.size())
{


for(auto i =a.begin(); i!= a.end()-1;)
{
    if(*i < m &&  *i + *(i+1) <= m)
    {
        *(i+1)= *(i)+ *(i+1);
        ans++;
        a.erase(i);
    }
    else if( *i == m )
    { i++; }

    else i++;


}
for(i=0;i<a.size();i++)
{
    if(a[i]== m)
        mp[m]++;
}
if(mp[m]!=a.size())
{
    int x=1;
    while( sum % (sum/m -x) !=0)
        x++;
      //  cout<<m<<"   fkf";
       m= sum / (sum/m -x );

           //for(int i=0;i<a.size();i++)
            //cout<<a[i]<<" ";
            //cout<<"fff\n";

       a.clear();
       for(i=0;i<n;i++)
        a.push_back(b[i]);
    mp.insert({m,0});
    ans=0;
}
}


//for(i=0;i<a.size();i++)
  //  cout<<a[i]<<" ";

 /* if(t==571 && xxx==80)
    {
        for(i=0;i<n;i++)
        cout<<b[i]<<" ";
    }
    else*/
     cout<<ans<<"\n";

}
}