#C7882. Minimum Operations to Make Array Elements Equal
Minimum Operations to Make Array Elements Equal
Minimum Operations to Make Array Elements Equal
Given an array of n integers, determine the minimum number of operations required to make all elements equal. In one operation, you can change any element to any other value. The optimal strategy is to convert all elements to the most frequent element, thus the answer is computed as:
$$n - \max_{x} f(x)$$
where \(f(x)\) is the frequency of element \(x\) in the array.
inputFormat
The first line contains an integer n, representing the number of elements in the array. The second line contains n space-separated integers.
outputFormat
Output a single integer: the minimum number of operations required to make all elements equal.
## sample3
1 2 3
2