#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ft first
#define sd second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define point pair <int, int>

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();
    int n;
    cin >> n;
    int a[n];
    for (int i = 0, x; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0, k = 0, prev = 0, cnt = 0;
    for (int i = n - 1; i >= 0; i--)
    {

        if (a[i] != prev)
        {
            prev = a[i];
            cnt += k;
            k = 0;
        }
        int x = max(0ll, a[i] - cnt);
        ans += x;
        k++;

    }
    cout << ans;


    return 0;
}
