#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld",n)
#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d",n);
#define _ ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
typedef long long int LL;
class node{
public:
LL ss;
LL length;
};
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<VL> VVL;
typedef pair<LL,LL> PLL;
typedef stack<node> st;
typedef queue<node> qu;
typedef pair<int ,int> II;
typedef vector<II> VII;
void FastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
LL a[100005];
int main()
{
LL n,i,j;
LL t;
cin >> t;
assert(t <= 20);
while(t--){
cin >> n;
assert(n <= 100000);
for(i=0;i<n;i++){
cin >> a[i];
assert(a[i] <= 1000000000);
}
LL ans=0;
bool flag =0;
for(i=0,j=n-1;i<=j;){
if(a[i] == a[j]){
i++ ;
j-- ;
}
else if(a[i] > a[j]){ // need to merge from tail.
j-- ;
a[j] += a[j+1] ;
ans++;
}
else{ // ned to merge from head.
i++ ;
a[i] += a[i-1];
ans++;
}
}
cout << ans << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZmYgZmlyc3QKI2RlZmluZSBzcyBzZWNvbmQKI2RlZmluZSBzeiBzaXplKCkKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBwZiBwdXNoX2Zyb250IAojZGVmaW5lIGZmIGZpcnN0CiNkZWZpbmUgc3Mgc2Vjb25kCiNkZWZpbmUgU0VUKGE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