Karl has an array of integers. He wants to reduce the array until all remaining elements are equal. Determine the fewest number of elements to delete to reach his goal.
For example, if his array is , we see that he can delete the elements and leaving . He could also delete both twos and either the or the , but that would take deletions. The minimum number of deletions is .
Input Format
The first line contains an integer , the number of elements in .
The next line contains space-separated integers .
Constraints
Output Format
Print a single integer denoting the minimum number of elements Karl must delete for all elements in the array to be equal.
Sample Input
5
3 3 2 1 3
Sample Output
2
Explanation
Array . If we delete and , all of the elements in the resulting array, , will be equal. Deleting these elements is minimal. Our only other options would be to delete elements to get an array of either or .
'HackerRank > Algorithms' 카테고리의 다른 글
Taum and B'day (0) | 2018.08.10 |
---|---|
ACM ICPC Team (0) | 2018.08.08 |
Jumping on the Clouds (0) | 2018.07.19 |
Repeated String (0) | 2018.07.19 |
Non-Divisible Subset (0) | 2018.07.19 |