#include<bits/stdc++.h>

using namespace std;
long long i,n,loss,res,c,cc;
long long a[1000007];

int main(){

   cin >> n;
   for(i=1; i<=n; i++) cin >> a[i];
   sort(a+1, a+1+n);
   for(i=n; i>=1; i--){
   if(a[i]==c && a[i]-loss+cc > 0)res+=a[i]-loss+cc;
   else if(a[i]-loss > 0) {res+=a[i]-loss; cc=0;}
   c=a[i];
   if(a[i]==c) cc++;
   a[i]=0;
   loss++;
   //cout << a[1] << a[2] << a[3] << a[4] << a[5] << endl;
   }
   cout << res;
    return 0;
}

