#include<bits/stdc++.h>
using namespace std;
#define mp make_pair 
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front

typedef long long ll;
typedef unsigned long long ull;
typedef short int si;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int nMax = 1e6+5;
const ll mod = 1e9+7;

ll t,n,arr[3005],sum,ans;

ll coba(ll x) {
    ll cnt = 0, op = 0;

    for (int i=0;i<n;i++) {
        if (cnt + arr[i] == x) {
            cnt = 0;
        }
        else if (cnt + arr[i] < x) {
            op++;
            cnt += arr[i];
        }
        else {
            return n;
        }
    }
    return op;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> t;
    while(t--) {
        cin >> n;
        sum = 0;
        for (int i=0;i<n;i++) {
            cin >> arr[i];
            sum += arr[i];
        }
        ans = n-1;
        for (int i=1;i*i<=sum;i++) {
            if (sum % i == 0) {
                ans = min(ans,coba(i));
                ans = min(ans,coba(sum/i));
            }
        }
        cout << ans << "\n";
    }
	return 0;
}