#include <bits/stdc++.h>

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main() { _
	int t; cin >> t;
	while (t--) {
		int n; cin >> n;
		vector<int> v(n);
		for (int& i : v) cin >> i;
		int ans = INF;
		int s = 0;
		for (int i = 0; i < n; i++) {
			s += v[i];
			int op = i;
			int first = i+1;
			bool ruim = 0;
			while (first < n) {
				int j = first;
				int s2 = 0;
				while (j < n and s2 < s) s2 += v[j++];
				if (s2 != s) {
					ruim = 1;
					break;
				}
				op += j - first - 1;
				first = j;
			}
			if (!ruim) ans = min(ans, op);
		}
		cout << ans << endl;
	}
	exit(0);
}

