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

long long a[100005],b,c,d,e,f,n,m,k,l,i,j,x,y,mi,ma,res;

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

    }
    sort(a+1,a+n+1);
    while(n>0)
    {
        c=0;
        i=n;
        while(a[i]==a[n])
        {
            c++;
            i--;
        }
        if(a[n]*c>0)
            res=res+a[n]*c;
        for(i=1; i<=n-c; i++)
            a[i]=a[i]-c;
        n=n-c;
    }
    cout<<res<<endl;


    return 0;
}
