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

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n; cin >> n;
    long long a[n];
    for (long long& i : a)cin >> i;
    sort(a, a + n, greater <long long>{});
    long long ans = 0;
    long long prev = -1, discount = 0, pdiscount = 0;
    for (long long i = 0; i < n; i++) {
        if (a[i] != prev) {
            pdiscount = discount;
            if (a[i] - discount > 0)
                ans += a[i] - discount;
        } else {
            if (a[i] - pdiscount > 0)
                ans += a[i] - pdiscount;
        }
        prev = a[i];
        discount++;
    }
    cout << ans << endl;
}
