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
#pragma GCC optimize("O3,unroll-loops") 
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
//a poem about frogs
 
#include <bits/stdc++.h>
 
#define st first
#define nd second
#define eb emplace_back
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define mp make_pair
#define ii pair<int, int>
#define all(a) a.begin(), a.end()
#define fastio() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(a, b) for (int a = 0; a < b; ++a)
 
using namespace std;
const int maxn = 5e5;

int main() {
	fastio();
	int n;
	cin >> n;
	vi v(maxn);
	rep(i, n) {
		int j;
		cin >> j;
		--j;
		++v[j];
	}
	sort(all(v));
reverse(all(v));
	int sm=0;
	rep(i, n) {
		sm += 2*v[i]-1;
		if (sm >= n) {
			cout << i+1 << '\n';
			return 0;
		}
	}
	return 0;
}