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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back

int il[500009];

bool cmp(int a, int b){ return a > b;}

int main(){
	int n;
	cin>>n;
	int nn = n;
	for(int i = 1; i <= n; i++){
		int x;
		cin>>x;
		il[x]++;
	}
	sort(il + 1, il + n + 1, cmp);
	for(int i = 1; i <= n; i++){
		//cout<<il[i]<<" "<<nn<<endl;
		nn -= il[i];
		nn -= (il[i] - 1);
		if(nn <= 0){
			cout<<i<<endl;
			return 0;
		}
	}
}