Problem: Polycarp was gifted an array of length . Polycarp considers an array beautiful if there exists a number , such that each number in the array occurs either zero or times. Polycarp wants to remove some elements from the array to make it beautiful.
For example, if and , then the following options are possible to make the array array beautiful:
- Polycarp removes elements at positions and , array becomes equal to ;
- Polycarp removes elements at positions and , array becomes equal to ;
- Polycarp removes elements at positions and , array becomes equal to ;
Help Polycarp determine the minimum number of elements to remove from the array to make it beautiful.
Input Format: The first line contains one integer () — the number of test cases. Then test cases follow.
The first line of each test case consists of one integer () — the length of the array .
The second line of each test case contains integers () — array .
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case, output one integer — the minimum number of elements that Polycarp has to remove from the array to make it beautiful.