#include <bits/stdc++.h>

using namespace std;

int n;
long long a[100005];
long long result;
long long x, counter;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }


    sort(a+1, a+1+n);
    reverse(a+1, a+1+n);
    x = 1;
    result = a[1];
    counter = 1;


    for (int i = 2; i <= n; i++) {
        if (a[i] == a[i-1]) {
            if ((a[i] - x + 1 * counter) > 0)  {
                result += a[i] - x + 1 * counter;
                x++;
                counter++;
            }          

        }
        else {
            counter = 1;
            if (a[i] - x > 0) {
                result += a[i] - x;
                x++;
            }
            
        }
    }
    
    cout << result << endl;
    return 0;
}