#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
int n;
std::unordered_map<int, int> counts;
void input() {
    std::cin >> n;
    for(int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        counts[x]++;
    }
}
int solve() {
    std::vector<int> v;
    for (auto e : counts) {
        v.push_back(e.second);
    }
    std::sort(v.begin(), v.end(), [](int v1, int v2){ return v1 > v2; });
    int result = 0, covered = 0;
    while(covered < n) {
        covered += (2 * v[result] - 1);
        result++;
    }
    return result;
}
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    input();
    std::cout << solve() << "\n";
    return 0;
}
        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  | #include <iostream> #include <unordered_map> #include <vector> #include <algorithm> int n; std::unordered_map<int, int> counts; void input() { std::cin >> n; for(int i = 0; i < n; i++) { int x; std::cin >> x; counts[x]++; } } int solve() { std::vector<int> v; for (auto e : counts) { v.push_back(e.second); } std::sort(v.begin(), v.end(), [](int v1, int v2){ return v1 > v2; }); int result = 0, covered = 0; while(covered < n) { covered += (2 * v[result] - 1); result++; } return result; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); input(); std::cout << solve() << "\n"; return 0; }  | 
            
        
                    English