#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define mx 501000
ll arr[mx],cum[mx];
int  main()
{
         ll t;
         cin>>t;
         while(t--)
         {
            ll n;
            cin>>n;
            for(ll i=0;i<n;i++)
            {
                cin>>arr[i];
            }
            cum[0]=arr[0];
            for(ll i=1;i<n;i++)
            {
                cum[i]=arr[i]+cum[i-1];
            }
            ll ans=n-1;
            for(ll i=0;i<n;i++)
            {
               ll sum=cum[i];
               ll mx1=i;
               ll k=i+1,flag=0; ll l=k,sol=0;
               while(k<n)
               {
                   if(l==n)
                   {
                       break;
                   }
                   sol=sol+arr[l];

                   if(sol==sum)
                   {
                       if(l==n-1)
                       {
                           mx1=mx1+l-k;
                           ans=min(ans,mx1);
                           flag=1;
                           break;
                       }
                       else
                      {
                          mx1=mx1+l-k;
                          k=l+1;
                          l=k;
                          sol=0;
                      }
                   }
                   else if(sol>sum) break;
                   else
                   {
                       l++;
                   }

               }
            }
             cout<<ans<<"\n";

         }

         }

