#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int solve(int n, vector<int> &A) {
	int ans = 0, sum = 0;
	for(auto a : A)
		sum += a;

	for(; ans < n; ans++) {
		int parts = n - ans;
		if(sum % parts > 0)
			continue;
		int itr = 0, tmp = 0;
		while(itr < n) {
			// cout<<itr<<' ';
			tmp += A[itr];
			itr++;
			if(tmp == sum / parts)
				tmp = 0;
			else if(tmp > sum / parts)
				break;
		}
		// cout<<'\n';
		if(itr == n and tmp == 0)
			return ans;
	}

	return n;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		int n;
		cin >> n;
		vector<int> vc(n, 0);
		for(auto &v : vc)
			cin >> v;
			
		cout << solve(n, vc) << '\n';
	}
	return 0;
}