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
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n;
    std::cin >> n;
    std::vector<int> v(n, 0);
    for(int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        v[a-1]++;
    }

    std::sort(v.begin(), v.end(), std::greater<>());

    int i = 0;
    int sum = 0;
    while(sum < n) {
        sum += v[i] * 2 - 1;
        ++i;
    }
    std::cout << i << "\n";
}