#include <bits/stdc++.h>

#define itn long long
#define int long long
//#define double long double
//#define endl '\n'
#define p_b push_back
#define fi first
#define se second
#define pii pair<int, int>
#define oo LLONG_MAX
#define elif else if

using namespace std;

int input()
{
    int x;
    cin>>x;
    return x;
}


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

//        freopen("divisor.dat", "r", stdin);
//        freopen("prpr.txt", "w", stdout);

    int n;
    cin>>n;
    map<int, itn>mp;
    for(int i=0;i<n;i++)mp[-input()]++;
    itn k=0, ans=0;
    for(auto x:mp)
    {
        int p=-x.fi;
        p-=k;
        ans+=max(0ll, p)*x.se;
        if(p>0)
        k+=x.se;
    }
    cout<<ans;


}
