#include <bits/stdc++.h>
#define int long long

using namespace std;

int n;
int a[101010];
int32_t main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> a[i];

    int cur = 0, ans = 0;
    map<int, int> sv;
    for (int i = 1; i <= n; i++)
        sv[a[i]]++;
    vector<pair<int, int> > hv;
    for (auto [i, j] : sv)
        hv.push_back({i, j});
    sort(hv.begin(), hv.end(), [](pair<int, int> q, pair<int, int> w) {
        return q.first > w.first;
    });
    int esc = 0;
    for (int i = 0; i < hv.size(); i++) {
        hv[i].first -= esc;
        if (hv[i].first < 1)continue;
        ans += (hv[i].first * hv[i].second);
        esc += hv[i].second;
    }
    cout << ans;
}
