#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define i_am_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define se second
#define fi first
#define INF 1e9+7
#define pb push_back
#define pf push_front
typedef pair <long long, long long> pll;

const long long DIM=2e5+7;

long long n, a[DIM], p, v, s, vn;

int main()
{
    i_am_speed
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    sort(a+1, a+1+n);
    for(int i=n; i>=1; i--){
        if(a[i]-v<=0) continue;
        if((a[i]-v)+vn==p){
            s+=(a[i]-v)+vn;
        }
        else{
            p=a[i]-v;
            s+=a[i]-v;
            vn=0;
        }
        v++;
        vn++;
    }
    cout << s << endl;



    return 0;
}
