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

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

    long long n;
    cin >> n;
    long long a[n] = {0};
    for (long long i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long summ = a[n-1];
    long long cnt = 1;
    long long comp = 0;
    long long q = 0;
    for (long long i = n - 2; i >= 0; i--) {
        if (a[i] != a[i+1]) {
            summ += max(a[i] - cnt, comp);
            q = cnt;
            cnt++;
        } else {
            summ += max(a[i] - q, comp);
            cnt++;
        }

        //cout << summ << " " << cnt << " " << a[i] << endl;
    }
    cout << summ;
}
