#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;
}