#include <bits/stdc++.h>

using namespace std;

int main()
{
    long n;
    cin>>n;
    vector<long> a(n);
    for(long i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end(), greater<long>());
    long long sum=a[0], del=1, temp=1;
    //cout<<sum<<'\n';
    for(long i=1; i<n; i++){
        if(a[i]==a[i-1] && a[i]<=(del-temp)){
            break;
        }
        if(a[i] >= del){
            sum += a[i] - del;
            if(a[i] == a[i-1]){
                sum += temp;
                temp++;
            }
            else{
                temp = 1;
            }
            del++;
            //cout<<i<<' '<<sum<<' '<<del<<'\n';
        }
        else{
            break;
        }
    }
    cout<<sum<<'\n';
    return 0;
}
