#include <iostream>

using namespace std;

int compare(const void* a, const void* b)
{
    const int* x = (int*)a;
    const int* y = (int*)b;

    if (*x > *y)
        return 1;
    else if (*x < *y)
        return -1;

    return 0;
}

int a[100000];

int main() {
    int n, max1 = 0, res = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > max1)max1 = a[i];
    }
    qsort(a, n, sizeof(int), compare);

    bool k = true;
    while (k) {
        bool t = true;
        bool mm = false;
        for (int i = n; i > 0; i--) {
            if (a[i] > 0 && !mm) {
                mm = true;
                max1 = a[i];
                a[i] = 0;
                t = false;
                res += max1;
            }
            if (a[i] != max1) {
                a[i]--;
            }
        }
        if (t)k = false;
    }
    cout << res;
    return 0;
}
