#K85057. Make Tower Heights Equal

    ID: 36556 Type: Default 1000ms 256MiB

Make Tower Heights Equal

Make Tower Heights Equal

You are given N towers with heights \(h_1, h_2, \dots, h_N\). In one operation, you can change the height of any tower to match the height that appears most frequently among all towers. Your task is to determine the minimum number of operations required to make all the towers have the same height.

Formally, if the frequency of a height \(x\) appearing in the list is \(f(x)\), the minimum number of operations needed is:

[ \text{operations} = N - \max_{x}(f(x)) ]

Note: You are not required to perform the actual operations; simply compute and output the minimum number.

inputFormat

The input is given via standard input and consists of:

  1. An integer N on the first line, representing the number of towers.
  2. A line containing N space-separated integers representing the heights of the towers.

outputFormat

Output a single integer via standard output representing the minimum number of operations required to make all the towers of equal height.

## sample
5
5 2 3 9 7
4