#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    long long sum = 0;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int number;
        cin >> number;
        v.push_back(number);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++)
        if (v[i] <= v.size() - i - 1 && v[i] < v[v.size() - 1])
            v[i] = 0;
        else
            break;
    int place = v.size() - 1;
    while (v[place] > 0 && place >= 0) {
        int i = place - 1 ;
        while (v[i] > 0 && i >= 0) {
            if (v[i] != v[place])
                v[i]--;
            i--;
        }
        sum += v[place];
        place--;
        //for (int i = 0; i < v.size(); i++)
            //cout << v[i] << ' ';
        //cout << endl;
    }
    cout << sum;
}