#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int number;
        cin >> number;
        v.push_back(number);
    }
    v.push_back(0);
    sort(v.begin(), v.end(), greater<int>());
    int dec1 = 0;
    int i = 0;
    long long sum = 0;
    while (i < v.size() && v[i] - dec1 > 0) {
        sum += v[i] - dec1;
        i++;
        if (v[i - 1] != v[i])
            dec1 = i;
    }
    cout << sum;
}