#include<bits/stdc++.h>
using namespace std;
long long broene[1005];
long long mesta[1005];
int main(){
    long long n, a;
    cin>>n;
    for(long long i = 0; i < n; i++){
        cin>>a;
        broene[a] ++;
        mesta[a] ++;
    }
    for(long long i = 1; i <= 1000; i++){
        if(broene[i] == 0) continue;
        if(broene[i] > broene[i + 1]){
                broene[i] -= broene[i + 1];
                mesta[i + 1] = 0;
        }else{
            mesta[i + 1] -= broene[i];
            broene[i] = 0;
        }
    }
    for(long long i = 1000; i >= 1; i--){
        long long j = i - 1;
        while(j >= 1 && mesta[i] > 0){
            ///cout<<"i: "<<i<<"     "<<"j: "<<j<<endl;
            ///cout<<"\t"<<"Mesta[i]: "<<mesta[i]<<endl;
            if(broene[j] > 0){
               /// cout<<"\t\tI.";
                if(broene[j] > mesta[i]){
                    broene[j] -= mesta[i];
                    mesta[i] = 0;
                    ///cout<<"I";
                }else{
                    broene[j] = 0;
                    mesta[i] -= broene[j];
                    ///cout<<"II";
                }
            }
            ///cout<<endl<<endl;
            j--;
        }
    }
    long long ans = 0;
    for(long long i = 1; i <= 1000; i++){
        ans += broene[i] * i;
    }
    cout<<ans<<endl;
    return 0;
}
