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
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <set>
#include <cstdlib>
#include <ctime>
#include<chrono>
#include<thread>
#include<iomanip>
#include<fstream>
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

using namespace std;

int main()
{
    int maxik = 1;
    map <int, int> count;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(count.count(a)) count[a]++;
        else count[a] = 1;
        maxik = max(count[a], maxik);
    }
    if(maxik == 1) {
        cout << n << endl;
    }
    else {
        int counter = 0;
        vector<int> ans;
        for(auto it : count) {
            ans.push_back(it.second);
        }
        sort(ans.begin(), ans.end());
        for(int i = ans.size() - 1; i >= 0; i--) {
            n -= ans[i] * 2;
            n += 1;
            counter++;
            if(n <= 0) break;
        }
        cout << counter;
    }
    return 0;
}