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
#include "bits/stdc++.h"

using namespace std;

#define ff first
#define ss second
#define mp make_pair
#define pb push_back
using ll=long long;
using cll=const ll;
using pll=pair<ll,ll>;
using pii=pair<int,int>;

int inp[500'005];


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);

    int n;
    cin >> n;
    deque<int> v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        inp[x]++;
    }

    for(int i = 0; i < 500'005; i++){
        if(inp[i] > 0) v.pb(inp[i]);
    }
    sort(v.begin(), v.end());

    int ans = 0;
    while(!v.empty()){
        ans++;
        int ileodj = v.back()-1;
        v.pop_back();
        while(!v.empty() && v.front() <= ileodj){
            ileodj -= v.front();
            v.pop_front();
        }
        if(v.empty()) break;
        v.front() -= ileodj;
    }

    cout << ans << endl;
    return 0;
}