#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0;i < n; i++) {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    long long int ans = 0;
    int dif = 0;
    int pos = 1e9+1;
    int y = 0;
    // 3 4 4 5 5
    for (int i = n-1;i>=0;i--) {
        if (a[i]!=pos){
            dif += y;
            y = 0;
            pos = a[i];
        }
        y++;
        if (a[i] - dif <= 0) {
            break;
        }
        else ans += a[i]-dif;
    }
    cout<<ans;
}
