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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
#define nl cout<<endl;
using namespace std;
const int maxn = 5e5+1;
vector<int> a(maxn);

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

void solve(int n) {
    int licznik = 0;
    int res = 1;
    for (int i = n; i > 0; i--) {
        if (a[i] == 0) break;
        licznik += a[i] + a[i]-1;
        if (licznik >= n) break;
        res++;
    }
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n = readInt();
    a.resize(n+1);
    for (int i = 0; i < n; i++) {
        int x = readInt();
        a[x]++;
    }
    sort(a.begin(), a.end());
    solve(n);
}