#include<bits/stdc++.h>
using namespace std;
long long broene[1005];
long long after[1005];
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n, a;
    cin>>n;
    for(long long i = 0; i < n; i++){
        cin>>a;
        broene[a] ++;
    }
    a = -1;
    for(long long i = 0; i <= 1000; i++){
        if(broene[i] == 0) continue;
        if(a == -1) a = i;
        else{
            after[a] = i;
            a = i;
        }
    }
    for(long long i = 1; i <= 1000; i++){
        if(broene[i] == 0) continue;
        if(broene[i] > broene[after[i]]) broene[i] -= broene[after[i]];
        else broene[i] = 0;
    }
    long long ans = 0;
    for(long long i = 1; i <= 1000; i++){
        ans += broene[i] * i;
    }
    cout<<ans<<endl;
    return 0;
}
