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

int balls[100005];

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

	int n;
	cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> balls[i];
    sort(balls, balls + n);
    int removed = 0, result = 0, price;
    while (removed < n)
    {
        if (removed == 0 || balls[n - removed - 1] != balls[n - removed])
            price = balls[n - removed - 1] - removed;
        if (price <= 0)
            break;
        result += price;
        ++removed;
    }
    cout << result << '\n';
}
