#include <bits/stdc++.h>
using namespace std;

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

	long long n, s = 0;
	cin>>n;
    vector <int> v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());
    s += v[0];
    int l = v[0], cnt = 1, cnt2 = 0;
    for(int i = 1; i < v.size(); i++)
    {
        if(v[i] == l)
        {
            while(v[i] == l)
            {
                s += v[i];
                l = v[i];
                i++;
                cnt++;
            }
        }
        else
        {
            if(v[i] - cnt > 0)
            {
                s += v[i] - cnt;
            }
            cnt++;
        }
        l = v[i];
    }
    cout << s;
}
