#include <bits/stdc++.h>
using namespace std;

int n;
long long money = 0, e;
vector <long long> v;

void erss(){
    long long a = v[0];
    v.erase(v.begin());

    for (long long i = 0; i < v.size(); i++){
        if (v[i] != a){
            v[i] -= 1;
        }
    }
    money += a;
    }

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	cin >> n;
    for (int i = 0 ; i < n; i++){
        cin >> e;
        v.push_back(e);
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    while (v[0] > 0){
        for (int i = 0; i < count(v.begin(), v.end(), v[0]); i++){
            erss();
        }
    }
    
    cout << money;
}
