#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	register int res=0;
	register char c=getchar(),f=1;
	while(c<48||c>57){if(c=='-')f=0;c=getchar();}
	while(c>=48&&c<=57)res=(res<<3)+(res<<1)+(c&15),c=getchar();
	return f?res:-res;
}
inline void write(int x){
	register char c[21],len=0;
	if(!x)return putchar('0'),void();
	if(x<0)x=-x,putchar('-');
	while(x)c[++len]=x%10,x/=10;
	while(len)putchar(c[len--]+48);
}
#define space(x) write(x),putchar(' ')
#define enter(x) write(x),putchar('\n')

const int N=1e5+10;
int n,a[N],s;
bool chk(int s){
	int now=0;
	for(int i=1;i<=n;++i){
		now+=a[i];
		if(now>s)return 0;
		if(now==s)now=0;
	}return 1;
}

int solve(){
	n=read(),s=0;
	for(int i=1;i<=n;++i)a[i]=read(),s+=a[i];
	for(int i=n;i;--i)if(!(s%i))
		if(chk(s/i))return n-i;
}

int main(){
	int T=read();
	while(T--)enter(solve());
}