#K4496. Amelia's Array Equivalence Challenge

    ID: 27647 Type: Default 1000ms 256MiB

Amelia's Array Equivalence Challenge

Amelia's Array Equivalence Challenge

Amelia's Array Equivalence Challenge is a coding problem that asks you to determine the minimum number of operations required to make all elements in an array equal. In each operation, you can select any two distinct elements from the array and replace both with their sum. The key observation is that the minimum number of operations required equals the number of unique elements in the array minus one.

Your task is to implement a solution that, for each given test case, computes the required number of operations. Use the standard input (stdin) for receiving test cases and print the results to the standard output (stdout), with each result on a separate line.

inputFormat

The input is taken from standard input. The first line contains an integer T, representing the number of test cases. Each test case consists of two lines:

  • The first line contains a single integer n, denoting the number of elements in the array.
  • The second line contains n space-separated integers, which are the elements of the array.

outputFormat

For each test case, output a single integer representing the minimum number of operations required to make all elements equal. Print each result on a new line.## sample

3
3
2 4 6
4
1 1 1 1
5
1 2 3 4 5
2

0 4

</p>