#include <bits/stdc++.h>
using namespace std;
long long n, a1[1001], b;
vector <int> a;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    long long sum=0;
    for (int i=0; i<n; i++)
    {
        cin>>b;
        a1[b]++;
        sum+=b;
        if (a1[b]==1)
        {
            a.push_back(b);
        }
    }
    sort(a.begin(), a.end());
    long long i=1;
    while (i<a.size())
    {
        if (a1[a[i]]>a1[a[i-1]])
        {
            sum-=a1[a[i-1]]*a[i-1];
        }
        else
        {
            sum-=a1[a[i]]*a[i-1];
        }
        i++;
    }
    cout<<sum<<"\n";
    return 0;
}