#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define endl '\n'
#define inf 1000000007
#define MN 100007

ll n,k,i,j,r,l,p,pnp,mp,res,sp;
ll a[100007];
string s;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];

    sort(a+1,a+1+n);
    pnp=a[n];
    res+=a[n];
    mp=1;

    for(i=n-1;i>=1;i--){
        if(a[i]==pnp){
            res+=a[i]-sp;

        }
        else if(a[i]!=pnp && a[i]-mp>0){
            pnp=a[i];
            res+=a[i]-mp;
            sp=mp;
        }
        mp++;
    }
    cout<<res;



return 0;
}
