#K95652. Minimum Operations to Equalize Arrays

    ID: 38911 Type: Default 1000ms 256MiB

Minimum Operations to Equalize Arrays

Minimum Operations to Equalize Arrays

You are given one or more test cases. For each test case, you are provided with an array of n integers. Your task is to determine the minimum number of operations required to make all the integers in the array equal. In one operation you can decrease any element by 1.

The optimal strategy is to make every element equal to the minimum element of the array. Formally, let \(A = [A_1, A_2, \dots, A_n]\) be the array and let \(m = \min\{A_1, A_2, \dots, A_n\}\). The number of operations needed is:

[ \text{operations} = \sum_{i=1}^{n} (A_i - m)]

Implement a program that reads the input from standard input (stdin) and outputs the result for each test case to standard output (stdout).

inputFormat

The first line of input contains an integer T representing the number of test cases.
Each test case consists of two lines:
- The first line contains an integer n, the number of elements in the array.
- The second line contains n space-separated integers.

outputFormat

For each test case, output a single integer representing the minimum number of operations needed to equalize the array. Each result should be printed on a new line.

## sample
1
1
5
0

</p>