#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <iostream>
#include <vector>

#define pb push_back

using namespace std;
using ll = long long;
using ull = unsigned long long;
using dl = double;

const ll N = 100100;
const ll inf = 100000000000;

ifstream in("input.txt");
ofstream out("output.txt");

ll n;
ll a[N];

int main() {

    in >> n;
    for (ll i = 0; i < n; ++i) {
        in >> a[i];
    }

    sort(a, a + n);

    ll bias = 0;
    ll sum = 0;

    for (ll i = n - 1; i >= 0; --i) {
        ll p = a[i];
        ll b = bias;
        for (ll j = i; j >= 0; --j) {
            if (a[j] != p) {
                break;
            }
            i = j;
//            out << p << endl;
            sum += max(0ll, p - b);
//            out << max(0ll, p - b) << endl;
            bias += 1;
        }
//        out << "#############" << endl;
//
//        for (ll j = 0; j < n; ++j) {
//            out << a[j] - bias << endl;
//        }
//        out << "#############" << endl;
    }
    out << sum << endl;

    return 0;
}