#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <numeric>

#define ll long long

using namespace std;

int main() {
  ll t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    vector<ll> a(n);        
    for (ll i = 0; i < n; i++) cin >> a[i];    
    ll sum = accumulate(a.begin(), a.end(), 0);
    bool flag(false);
    ll ans(n - 1);
    for (ll k = 0; k < n - 1; k++) {
      if (sum % (n - k) == 0) {
        ll goal(sum / (n - k));
        ll i = 0;
        ll curr(0);
        for (i = 0; i < n; i++) {                 
          if (curr + a[i] < goal) {
            curr += a[i];
          } else if (curr + a[i] == goal) {
            curr = 0;            
          } else {
            break;
          }
        }
        if (i == n) {          
          flag = true;
          cout << k << '\n';
          break;
        }
      }
    }
    if (!flag) {
      cout << n - 1 << '\n';
    }
  }  
  return 0;    
}