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
#include <iostream>
#include <algorithm>
#define MAXN 500002

using namespace std;

int n, t;
int cc[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> t;
        cc[t]++;
    }
    sort(cc + 1, cc + n + 1, greater<>());
    int res = 0;
    int sum = 0;
    while (sum < n) {
        res++;
        sum += cc[res] * 2 - 1;
    }
    cout << res << "\n";
    return 0;
}