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
58
59
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,fma,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("sse,sse2,abm,mmx,sse3,tune=native")
using namespace std;
typedef long long lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;
#define ff first
#define dd second
#define mp make_pair
#define pb push_back
#define sz size()
#define For(i, s, a) for(int i = s; i < a; ++i)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).erase(unique(all(x)), (x).end())


int main(void) {
	int n;
    scanf("%d", &n);
    vector<int> ile(n + 1, 0);
    vector<pii> xd;

    For (i, 0, n) {
        int g;
        scanf("%d", &g);
        ile[g]++;
    }

    For (i, 0, n + 1) {
        if (ile[i])
            xd.push_back({ile[i], i});
    }

    sort(all(xd));
    deque<pii> dx(all(xd));

    int sc = 0;
    while (!dx.empty()) {
        auto big = dx.back();
        dx.pop_back();
        ++sc;
        int tmp = big.first;
        
        while (!dx.empty() && tmp > 0) {
            auto smol = dx.front();
            dx.pop_front();
            if (tmp > smol.first) {
                tmp -= smol.first;
                continue;
            }
            dx.push_front({smol.first - (tmp - 1), smol.second});
            tmp = 0;
        }
    }

    printf("%d", sc);
}