


Given ‘N’ = 4 and ‘ARR’ = [1, 1, 2, 2].
The answer will be 2, i.e., if we chose that all buckets should have 1 unit of water, we will have to throw 1 unit of water from buckets 3 and 4. Hence 2.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single integer 'N', where ‘N’ is the number of elements of the array.
The second line of each test case contains ‘N’ space-separated integers, denoting the array elements.
For each test case, print a single line containing a single integer denoting the minimum water we will have to throw.
The output of each test case will be printed in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 2000
1 <= ARR[i] <= 100
Where ‘T’ is the total number of test cases, and 'N’ is the length of the array and ‘ARR[ i ]’ is array element at index ‘i’.
Time limit: 1 sec.
The main idea is to use sorting the given array in reverse order and then check for the candidates for the water to be removed.