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

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

	LL n;
	cin>>n;
    LL arr[n];
    for(int i = 0; i < n; i += 1){
        cin>>arr[i];
    }
    LL ans = 0;
    sort(arr,arr+n);
    LL col = 0;
    LL curcol = 0;
    for(int i = n-1; i >= 0; i -= 1){
        if(arr[i] > curcol){
            ans += arr[i] - curcol;
        }
        else break;
        col += 1;
        if(i > 0 && arr[i] != arr[i - 1]){
            curcol = col;
        }
    }
    cout<<ans;
    return 0;
}
