#include <bits/stdc++.h>

using namespace std;

int n;
long long a[100005];
long long unsigned int result;
long long x;

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);

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