for _ in range(int(input())):
n = int(input())
nums = tuple(map(int, input().split()))
sum_nums = sum(nums)
for i in range(n, 0, -1):
nums_2 = list(nums)
if sum_nums % i == 0:
cnt = 0
ave = sum_nums // i
j = 0
while j <= len(nums_2) - 2:
while nums_2[j] < ave:
nums_2[j] += nums_2[j+1]
del nums_2[j+1]
cnt += 1
if nums_2[j] > ave:
break
elif nums_2[j] == ave:
j += 1
if nums_2 == [ave]*i:
print(cnt)
break