#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
const int N = 2e5 + 10;
int a[N];


int main() {
    int n;
    cin>>n;
    for(int i = 1;i <= n;i++){
        cin>>a[i];
    }
    sort(a + 1,a + n + 1);
    long long res = 0;
    int j = n + 1;
    int cnt = 1;
    while(j >= 2){
        j--;
        if(a[j] > 0 && j >= 1) res += a[j];
        else break;
        a[j - 1] = a[j - 1] - cnt;
        cnt++;
    } 
    cout<<res;
}
// 64 位输出请用 printf("%lld")