#C4600. Minimum Operations to Equalize Array Elements

    ID: 48157 Type: Default 1000ms 256MiB

Minimum Operations to Equalize Array Elements

Minimum Operations to Equalize Array Elements

Given an array of N integers, your task is to determine the minimum number of operations required to make all the elements in the array equal. In one operation, you can change any element to any other value.

The strategy is to choose the element that appears most frequently and convert all other elements into that element. The minimum number of operations is given by the formula:

$$N - \max\{frequency\}$$

where N is the total number of elements and frequency is the count of the most common element in the array.

inputFormat

The input is given via stdin and consists of two lines. The first line contains a single integer N (1 ≤ N ≤ 105), denoting the number of elements in the array. The second line contains N integers separated by spaces, representing the array.

outputFormat

Output a single integer via stdout which is the minimum number of operations required to make all elements in the array equal.

## sample
4
1 2 3 4
3