#include<bits/stdc++.h>

#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define pof pop_front()
#define puf push_front
#define lb lower_bound
#define ub upper_bound

using namespace std;

int t, n, a[4001], b[4001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> t;

    while(t--)
    {
        cin >> n;
        int sum = 0;

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

        for (int i = n; i > 0; i--)
        {
            if (sum % i)
                continue;

            bool bo = 1;

            for (int j = 1; j <= n; j++)
                b[j] = a[j];

            for (int j = 1; j <= n; j++)
            {
                if (b[j] > sum / i)
                {
                    bo = 0;
                    break;
                }

                if (b[j] == sum / i)
                    continue;

                if (b[j] + b[j + 1] > sum / i)
                {
                    bo = 0;
                    break;
                }

                b[j + 1] += b[j];
            }
            
            b[n + 1] = 0;

            if (bo)
            {
                cout << n - i << "\n";
                break;
            }
        }
    }
}
