#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
using namespace std;
ll ch=1e18;
ll a,b,c,d,x,n,n1,n2,fl1,fl2,o1,o2,flag,flag1,flag2,g,m,m1,m2,i,j,lr,f,k,l,r,y,o,p,mx=-ch,mx1=-ch,mx2=-ch,q,q1,q2,q3,q4,mn=ch,mn1=ch,mn2=ch,f1,f2,pos,ans,sum,sz=1,MOD=1e9+7;
ll A[200005];
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+n+1);
    for(i=n;i>=1;i--)
    {
        if (i!=n&&A[i]==A[i+1]) f2++;
        else f2=0;
        if (A[i]-(f1-f2)>=0) f+=(A[i]-(f1-f2));
        f1++;
    }
    cout<<f<<"\n";
}
