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

#define DIM 100007
#define fi first
#define se second


typedef long long ll;

ll t, c, a[DIM], n, res, x, y, b, k, x1, x2, m, res1, res2;
string s1, s2;


int main(){
    
    
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        
    }
    res = 0;
    c = 1;
    k = 0;
    sort(a+1, a+1+n);
    for(int i=n-1;i>=1;i--){
        if(a[i]==a[i+1]){
            c++;
        }
        else{
            if(a[i+1]>k) res += (a[i+1] - k) * c;
            k += c;
            c = 1;
            

        }
    }
    
    if(a[1]>k) res += (a[1] - k) * c;
    
    cout<<res<<endl;
    //cout<<res1<<" "<<res2<<endl;
    
    return 0;
}

