#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <iomanip>
#include <set>
#include <cmath>

#define LF '\n'

using namespace std;
typedef long long int lli;

vector<lli> a;

void solve()
{
    int n;
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    lli cnt = 0, prevcnt = 0;
    lli p = a[0];
    lli ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == p) {
            if (a[i] <= prevcnt) break;
            ans += (a[i] - prevcnt);
            cnt++;
        }
        else {
            if (a[i] <= prevcnt) break;
            p = a[i];
            prevcnt = cnt;
            if (a[i] <= prevcnt) break;
            ans += (a[i] - prevcnt);
            cnt++;
        }
    }
    cout << ans;
}

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif


    solve();
}

