#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
  ll t_c = 1;
  cin >> t_c;

  for(ll t = 1; t <= t_c; t++)
  {
    ll n;
    cin >> n;

    ll arr[n];
    vector<ll> preFix(n+1, 0);

    for(ll i=0; i<n; i++)
    {
      cin >> arr[i];
      preFix[i+1] = preFix[i] + arr[i];
    }

    ll ans = 5000;

    for(ll i=1; i<=n; i++)
    {
      ll tmp_ans = i-1;
      ll val = preFix[i];
      ll index = i;
      ll cur_val = 0;
      for(ll j=i+1; j<=n; j++)
      {
        cur_val = preFix[j] - preFix[index];
        // cout << "debug i: " << i << " val: " << val << " cur_val: " << cur_val << " j: " << j << endl;

        if(cur_val == val)
        {
          cur_val = 0;
          tmp_ans += j - index - 1;
          index = j;
        }
      }

      if(cur_val == 0)
      {
        ans = min(ans, tmp_ans);
      }
    }

    cout << ans << endl;

  }

  return 0;
}