#K85057. Make Tower Heights Equal
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:
- An integer N on the first line, representing the number of towers.
- 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.
## sample5
5 2 3 9 7
4