#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

typedef pair<int, int> pi;

#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

/*
- gotta make all elements equal
- problem reduces to pick 2 consecutive elemnts and replace then by their sum
- brute force ans from 0 to n-1 and check if that can be ans
- rather brute force final number of elements after some x operations
*/

void solve() {

	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	// brute force final number of elements:
	for (int cnt = n; cnt >= 0; cnt--) {
		if (sum % cnt != 0) {
			continue;
		}

		int final = sum / cnt;
		bool nope = false;

		for (int i = 0, j = 0; i < n; i = j) {
			int curSum = 0;
			while (j < n and curSum + a[j] <= final) {
				curSum += a[j];
				j++;
			}
			if (curSum != final) {
				nope = true;
				break;
			}
		}

		if (nope == false) {
			cout << n - cnt << endl;
			return;
		}
	}

}

int32_t main()
{
	IOS
	int T; cin >> T; while (T--)
		solve();
	return 0;
}
