#K61327. Minimum Operations to Unify Array

    ID: 31285 Type: Default 1000ms 256MiB

Minimum Operations to Unify Array

Minimum Operations to Unify Array

Given an array of n integers, the task is to determine the minimum number of operations required to make all elements equal. In one operation, you can change the value of any element to any other integer. The optimal strategy is to change all elements that are not equal to the most frequent element. Mathematically, if the frequency of the most common element is \(f_{max}\) and the total number of elements is \(n\), then the minimum number of required operations is:

\(n - f_{max}\)

This problem tests your ability to process arrays and compute frequencies efficiently.

inputFormat

The input is given via standard input (stdin) in the following format:

  1. An integer n representing the number of elements in the array.
  2. A line containing n space-separated integers.

You can assume that n is at least 1.

outputFormat

Output a single integer on a new line representing the minimum number of operations required to make all array elements equal.

## sample
6
4 7 4 4 4 7
2

</p>