We’re preparing your current view and syncing the latest data.
You are given an array of integers representing certain values. Your task is to determine the minimum number of operations required to make all the elements equal. Each operation consists of selecting one element and changing it according to specified rules defined in the problem.
The first line contains an integer t, 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 integers representing the array elements.
For each test case, output a single integer — the minimum number of operations required to make all elements equal.
1 ≤ t ≤ 1000 1 ≤ n ≤ 100 1 ≤ array elements ≤ 10^9
Example 1
Input
1 5 1 2 2 1 3
Output
2
Explanation
The minimum operations required to make all elements equal is 2 by changing the elements 1 and 3 to 2.