Given an array of integers of length .
The process consists of two stages.
In the first stage, you can choose some elements of the array and replace each of them with any integer.
In the second stage, individual elements can no longer be changed. Instead, you can perform the following operation any number of times: choose any subarray of the array and replace it with a single number equal to the sum of all elements of that subarray. After such an operation, the length of the array decreases.
For example, if the array looks like [2, 3, 4, 5, 6], you can choose the subarray [3, 4, 5] and replace it with the single number , since 3 + 4 + 5 = 12. After this, the array becomes [2, 12, 6].
What is the minimum number of elements that need to be replaced in the first stage so that in the second stage it is possible to obtain an array of the form [x, x, x] for some integer ?
The first line contains the number of test cases ( 10^4). The description of the test cases follows.
The first line of each test case contains one integer ( 2 \cdot 10^5) — the size of the array .
The second line contains integers a_1,a_2,\ldots,a_n ( a_i 10^9) — the elements of the array.
It is guaranteed that the sum of across all test cases does not exceed 2 \cdot 10^5.
For each test case, output a single integer — the minimum number of elements that need to be replaced in the first stage so that it is possible to obtain an array of the form [x, x, x] for some integer .
Example 1
Example 2
Example 3
For the first test case, the answer is since we can apply the first type of operation to the segment and obtain the array [3,3,3].
For the second test case, the answer is since we can apply the second type of operation once for i = 4 and make a_4 = 3. After that, we will apply the first type of operation to the segment and obtain the array [3,3,3].
For the third test case, the answer is since we can apply the second type of operation twice. The first time for i = 1 and the second time for i = 2.
Subtask ( points) : (a_i \le 10)
Subtask ( points) : (n \le 2 \cdot 10^3)
Subtask ( points) : No additional constraints