#include <bits/stdc++.h>

#define ll long long
#define us unsigned short
#define ui unsigned int

using namespace std;

ui n;
vector<int> a;
int used_range;
int j = 0;
ll money = 0;
int i;

int main() {
    cin >> n;
    i = n-1;
    ui elem;
    for (int i=0; i < n; i++) {
        cin >> elem;
        a.push_back(elem);
    }

    sort(a.begin(), a.end());

    while (i > 0) {
        used_range = a[i];
        if (a[i] != used_range)
            money += a[i]-j;
        else
            money += a[i];
        a.pop_back();
        i = a.size()-j-1;
        j++;
    }

    cout << money << '\n';

    return 0;
}
