#include<bits/stdc++.h>
using namespace std;
    // MrBB.TwinHTer
typedef long long ll;
typedef pair<int, int> ii;
typedef string str;
#define first fi
#define second se
#define For(i, a, b ,k) for(long long i = (a); i <=(b); i=i+(k))
#define Rep(i, a, b ,k) for(long long i = (a); i >=(b); i=i-(k))
#define pb push_back
#define pd (ll) 100000000007
const int base = 311;
const ll Hmod[] = {(ll)1e9 + 2277, (ll)1e9 + 5277, (ll)1e9 + 8277, (ll)1e9+ 9277};
//==========================Pt==========================
//==========================CT==========================
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int test_case;
        cin >> test_case;
        For(zz, 1, test_case, 1) {
       	ll n;
       	ll a[50000];
       	ll st = 0;
       		cin >> n;
       		For(i, 1, n, 1) {
       			cin >> a[i];
				st += a[i];	
			}
			
		ll minn = pd;
			For(i, 1, n, 1) {
				if(st % i == 0) {
				ll dem = 0, j = 1, sk = 0, t = 1, ktr = 0, s = st/i;
				
					while(j <= n ) {
						sk += a[j];
						if(sk > s) {
							ktr = 1;
							break;
						}
						
						if(sk == s) {
							dem = dem+j-t;
							sk = 0;
							t = j+1;
						}
						j++;
					}
					
					if(ktr == 0)
						minn = min(minn, dem);
				}
			}
			cout << minn << endl;
     }
}