#include<bits/stdc++.h>
using namespace std;
int a[100000], br[1001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        br[a[i]]++;
    }
    long long br2=0, d=0;
    for(int i=1000; i>0; i--)
    {
        br[i]-=br2;
        if(br[i]<=0) continue;
        br2+=br[i];
        d+=br[i]*i;
        //cout<<br[i]<<" "<<br2<<" "<<d<<endl;
    }
    cout<<d;
    return 0;
}
