#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5 + 7;

int t, n;
int a[N];

int main()
{

    scanf("%d", &t);
    while(t--)
    {
        scanf("%d", &n);
        int sum = 0;
        for (int i = 1; i <= n;i++)
        {
            scanf("%d", &a[i]);
            sum += a[i];
        }

        int f = -1;
        for (int i = n; i > 1;i--)
        {
            if(sum % i == 0)
            {
                int flag = 1;
                int lim = sum / i;
                int tmp = 0;
                for (int j = 1; j <= n;j++)
                {
                    tmp += a[j];
                    if(tmp == lim)
                        tmp = 0;
                    else if(tmp > lim)
                    {
                        flag = 0;
                        break;
                    }   
                }
                if(flag)
                {
                    f = i;
                    break;
                }
            }
        }

        if(f == -1) f = n - 1;
        else f = n - f;
        printf("%d\n", f);
    }

    return 0;
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              