#include <bits/stdc++.h>

using namespace std;

const long long MAX = 1e18, MIN = -1e18;
int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    long long n, x, ans = 0;
    cin >> n;
    long long mas[1000000];
    for (long long i = 0; i < n + 10; i++) mas[i] = 0;
    for (long long i = 0; i < n; i++)
    {
        cin >> x;
        mas[x]++;
    }
    for (long long i = n + 9; i > 0; i--)
    {
        if (mas[i] != 0)
        {
            x = mas[i];
            ans += x * i;
            mas[i] = 0;
            for (long long j = 1; j <= i - 1; j++)
                if (mas[j] != 0)
                {
                    if (j - x >= 1) mas[j - x] = mas[j];
                    mas[j] = 0;
                }
        }
    }
    cout << ans << endl;
    return 0;
}
