#include <iostream>
#include <algorithm>
#include <vector>
#define endl '\n'
using namespace std;

vector < pair <int, bool> > v;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    v.resize(n);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        v[i].first = a;
    }
    sort(v.begin(), v.end());
    int br = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (v[i].second == true) continue;
        br += v[i].first;
        v[i].second = true;
        int cur = v[i].first;
        for (int j = i - 1; j >= 0; j--)
        {
            if (v[j].second == true) continue;
            if (v[j].first != cur)
            {
                v[j].second = true;
                cur = v[j].first;
            }
        }
    }
    cout << br << endl;
}
