#include <bits/stdc++.h>
using namespace std;
int a[10005],cnt[1005];
int n,ans=0;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
cnt[a[i]]++;
}
for(int i=0;i<=1000;i++){
if(cnt[i]!=0){
int p=cnt[i];
while(1){
if(p>i+1){
p-=i+1;
ans+=i+1;
}
else{
ans+=i+1;
break;
}
}
}
}
cout<<ans;
return 0;
}