
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,int> a;
inline void solve(){
    ll sum = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a[x]++;
    }
    ll shift = 0;
    vector<pair<int,int>> tmp;
    for (auto e:a) {
        tmp.emplace_back(e);
    }
    for (int i = tmp.size()-1;i>=0;i--) {
        if(tmp[i].first-shift <=0) break;
        sum+=(tmp[i].first-shift)*tmp[i].second;
        shift+=tmp[i].second;
    }
    cout << sum << "\n";
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
    return 0;
}
