1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, lower, upper) for(int (i) = (lower); i <= (int)(upper); (i)++)
#define FORD(i, upper, lower) for(int (i) = (upper); i >= (int)(lower); (i)--)

const int N = 5e5;
int n;
int cnt[N + 1];

int main() {
    cin >> n;
    FOR(i, 1, n) {
        int x; cin >> x;
        cnt[x]++;
    }    
    sort(cnt + 1, cnt + 1 + (int)5e5, greater<int>());
    int sum = 0, i = 1, ans = 0;
    while(sum < n) {
        sum += 2 * cnt[i] - 1;
        ans++;
        i++;
    }
    cout << ans;
}