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

int main() 
{
 long long i,j,n,a[100001],k,max,f,p;
 map <long long, long long> m;
 cin >> n;
 for(i=0;i<n;i++)
 cin >> a[i];
 sort(a,a+n);
 k=0;
 j=0;
 i=n-1;
 f=1;
 while(f==1)
 {
 p=j;    
 while(a[i]==a[i-1])
 {        
 k=k+a[i]-p;
 i=i-1;
 j=j+1;
 }
 k=k+a[i]-p;
 i=i-1;
 j=j+1;
 if(i==-1)
 f=0;
 if(j>=a[i])
 f=0;
 }
 cout << k;
}
