#include <iostream>
#include <vector>
using namespace std;

int main(){
	int t; cin >> t;
	for (int pi = 0; pi < t; ++pi){
		int n; cin >> n;
		vector<int> str(n);
		for (int& e : str) cin >> e;
		int sum = 0;
		for (int& e : str) sum += e;
		for (int i = n; i >= 1; --i){ // Números restants al final
			if (sum%i == 0){
				bool possible = true;
				int k = 0;
				int partsum = 0;
				while (possible and k < n){
					partsum += str[k];
					if (partsum > sum/i) possible = false;
					else if (partsum == sum/i) partsum = 0;
					++k;
					
				}
				if (possible){
					cout << n - i << endl;
					break;
				}
			}
		}
	}
}
