#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
int tc;
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> tc;
    while(tc--) {
        int n;
        cin >> n;
        ll sum = 0, ans = LONG_LONG_MAX, arr[n];
        for(int i = 0;i < n;++i)
            cin >> arr[i];
        for(int i = 0;i < n;++i) {
            sum += arr[i];
            ll tmp_sum = 0, tmp_ans = i, cnt = 0;
            for(int j = i + 1;j < n;++j) {
                tmp_sum += arr[j];
                ++cnt;
                if (tmp_sum == sum)
                    tmp_ans += (cnt - 1), cnt = 0, tmp_sum = 0;
            }
            if(tmp_sum == 0)
                ans = min(ans, tmp_ans);
        }
        cout << ans << '\n';
    }
    return 0;
}