1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <algorithm>
using namespace std;

const int ILE = 500000;
int tab[ILE +1];

int main()
{
	int t, a, r = 0, w = 0;
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> a;
		if (tab[a]++ == 0)
		{
			r++;
		}
		
	}
	sort(tab, tab+t);
	reverse(tab, tab+t);
	for(int i = 0, j = r-1; i <= j;)
	{
		if(tab[i] > tab[j]) j--;
		else if(tab[i] <= tab[j]) 
		{
			i++;
			w++;
		}
	}
	cout << w;
}