#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <algorithm>
#include <iterator>
#define ll long long
using namespace std;

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, a[3000], sum = 0;
		cin >> n;
		for (int i = 0; i < n; i++)
			cin >> a[i], sum += a[i];
		for (int i = n; i > 0; i--)
		{
			if (sum % i == 0)
			{
				int J = sum / i, j = 0;
				bool flag = 0;
				for (int u = 0; u < n; u++)
				{
					j += a[u];
					if (j > J)
					{
						flag = 1;
						break;
					}
					else if (J == j)
						j = 0;
				}
				if (!flag)
				{
					cout << n - i << endl;
					break;
				}
			}
		}
	}
	return 0;
}