#include <iostream>
#include <algorithm>

using namespace std;

long long n, k, s;

long long a[100007];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    k = n;
    for (int i = 1; i <= n; i++) {
        s += k;
        k--;
        for (int j = 1; j <= k; j++) {
            a[i]--;
        }
    }
    cout << s-1 << endl;
}