#include <bits/stdc++.h>

#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define watch(x) cout << (#x) << " : " << x << '\n'
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &x : a)
        cin >> x;
    sort(rall(a));
    int offset = 0;
    int ans = 0;
    vector <int> saved = a;
    for (int i = 0; i < n; i++) {
        a[i] = max(a[i]-offset, 0ll);
        if (i && saved[i] == saved[i-1])
            a[i] = a[i-1];
        offset++;
        ans += a[i];
    }
    cout << ans << '\n';
}

main () {
    boost;
    solve();
    return 0;
}
