#include <bits/stdc++.h>
#define union Union
#define rank rank228
#define tm tm228
#define hash hash228
#define matr vector < vector < int > >
#define int long long
#define pii pair < int, int >
#define papa pair < Node*, Node* >
#define all(v) v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define PI 3.14159265358979323846
#define ff first
#define ss second
//#define mp make_pair
#define tri pair < pii, int >

using namespace std;

const int inf = 1e18, maxn = 3e5 + 100, mod = 1e9 + 7;

int a[maxn];

void solve(){
    int n, sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        sum += a[i];
    for (int k = n; k >= 1; --k)
    {
        if (sum % k)
            continue;
        int x = sum / k;
        int y = 0, ok = 1;
        for (int i = 0; i < n; ++i)
        {
            y += a[i];
            if (y > x)
            {
                ok = 0;
                break;
            }
            if (y == x)
                y = 0;
        }
        if(ok)
        {
            cout << n - k;
            return;
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    srand(100);
    cout << fixed << setprecision(6);
    int t = 1;
    #ifdef LOCAL
        freopen("task.in", "r", stdin);
    #endif
    cin >> t;
    while (t--)
    {
        solve();
        cout << endl;
    }
}
