#K40952. Minimizing Array Operations

    ID: 26756 Type: Default 1000ms 256MiB

Minimizing Array Operations

Minimizing Array Operations

You are given t test cases. In each test case, you are given an array of n non-negative integers. In one operation, you can choose two distinct elements of the array, say a[i] and a[j], and perform the following: set one of them to the absolute difference \(|a[i] - a[j]|\) and the other to 0.

Your goal is to make all elements in the array equal to 0 with the minimum number of operations. It can be proven that the answer is \(0\) if \(n=1\) and \(n-1\) if \(n>1\).

inputFormat

The first line of input contains an integer t (t \(\geq 1\)), indicating the number of test cases. For each test case, the first line contains an integer n (the number of elements in the array), and the second line contains n space-separated integers.

outputFormat

For each test case, output a single integer on a new line: the minimum number of operations required to make all array elements 0.

## sample
1
1
5
0

</p>