// Arup Guha
// 3/4/2022
// Solution to 2022 February Bronze USACO Problem: Sleeping in Class

import java.util.*;

public class sleep {

	public static int n;
	public static int[] vals;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process each case.
		for (int loop=0; loop<nC; loop++) {
		
			// Get the numbers. Store both max and sum.
			n = stdin.nextInt();
			vals = new int[n];
			int max = 0, sum = 0;
			for (int i=0; i<n; i++) {
				vals[i] = stdin.nextInt();
				max = Math.max(max, vals[i]);
				sum += vals[i];
			}

			// Special case.
			if (sum == 0)
				System.out.println(0);
			
			// Regular solve.
			else {
			
				// Can't be worse than this.
				int res = n-1;
				
				// d represents sum of numbers in each segment.
				for (int d=max; d<=sum/2; d++) {
					
					// Can't be equal.
					if (sum%d != 0) continue;
					
					// If we can do it, we have our answer. Store it and get out.
					if (canDo(d)) {
						res = n - sum/d;
						break;
					}
				}	
				
				// Ta da!
				System.out.println(res);
			}
		}
	}
	
	// Can we split the data into groups that all add to target.
	public static boolean canDo(int target) {
	
		// Current running sum for this segment.
		int cur = 0;
		
		// Go through each number.
		for (int i=0; i<n; i++) {
			
			// Update the running sum.
			cur += vals[i];
			
			// Great, we can cut it off.
			if (cur == target) {
				cur = 0;
			}
			
			// Oops, this means this sum is impossible.
			else if (cur > target)
				return false;
		}
		
		// If we make it here, we split everything up evenly.
		return true;
	}
}