def check(j):
s=0
for i in range(n):
s+=stone[i]
if s>j:
return False
if s==j:
s=0
return True
T=int(input())
for i in range(T):
n=int(input())
stone=list(map(int,input().split()))
sun=sum(stone)
for j in range(sun+1):
if j==0:
if check(0):
print(0)
else:
if sun%j==0 and check(j):
print(n-sun//j)
break