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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define FORR(i,a,b) for(int i=a; i>=b; i--)
#define For(n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define ps push
#define setbits(x) __builtin_popcountll(x)

const int MAX = 5e5+5;
const int INF = 1e9+5;
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;

int t[MAX+1];
multiset <int> secik;

int findMAX()
{
    int maxi;
    if(!secik.empty()) maxi=*(secik.rbegin());
    return maxi;
}

int findMIN()
{
    int mini;
    if(!secik.empty()) mini=*(secik.begin());
    return mini;
}

void solve()
{
    int n,a;
    cin>>n;
    FOR(i,1,n)
    {
        cin>>a;
        t[a]++;
    }
    FOR(i,1,MAX) if(t[i]) secik.insert(t[i]);

    //for(auto x: secik) cout<<x<<" ";
    int ans=0;
    while(!secik.empty())
    {
        ans++;
        int tmp=0;
        int maxi=findMAX();
        secik.erase(prev(secik.end()));
        while(!secik.empty() && findMIN()+tmp<maxi) {tmp+=findMIN(); secik.erase(secik.begin());}

        if(!secik.empty() && maxi-tmp-1>0)
        {
            secik.erase(secik.begin());
            secik.insert(maxi-tmp-1);
        }

    }
    cout<<ans;
}

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

    solve();

    return 0;
}