#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);
ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}

void solve() {
    int N; cin >> N;
    vecl A(N); REP(i,N) cin >> A[i];

    ll total = 0;

    REP(i,N) total += A[i];

    ll cum = 0;

    int ans = 1e9;

    REP(i,N) {
        cum += A[i];
        if(total%cum != 0) continue;
        vecl res,res2;
        res.push_back(cum);
        res2.push_back(i+1);

        int j = i+1;
        int l = j;
        ll cum2 = 0;
        while(j < N) {
            cum2 += A[j];
            if(cum == cum2) {
                res.push_back(cum2);
                res2.push_back(j-l+1);
                l = j + 1;
                cum2 = 0;
            }
            j++;
        }
        res.push_back(cum2);
        res2.push_back(j-l+1);

        // for(ll c : res2) cout << c << " ";
        // cout << endl;

        bool ok = true;
        int cnt = 0;
        REP(i,res.size()) {
            ll c = res[i];
            if(c == 0) continue;
            if(c != cum) ok = false;
            cnt += res2[i]-1;
        }

        if(ok) chmin(ans,cnt);   
    }

    cout<< ans << endl;

    
    return;
}

int main() {
    int T; cin >> T;
    while(T--) solve();
    return 0;
}