#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, cntw = 0;
    for(int i = 1; i < v.size(); i++)
    {
        if(v[i] == v[i - 1])
        {
            if(v[i] - cntw > 0)
            {
                s += v[i] - cntw;
            }
            else
            {
                break;
            }
        }
        else
        {
            if(v[i] - cnt > 0)
            {
                s += v[i] - cnt;
            }
            else
            {
                break;
            }
            cntw = cnt;
        }
        cnt++;
    }
    cout << s;
}
