#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);i++)
#define ll long long
const int maxn=1e5+10;
int n,a[maxn],cnt=0;
int main(){
cin>>n;
rep(i,1,n+1) cin>>a[i];
sort(a+1,a+1+n);
for(int i=n;i>=1;i--){
cnt++;
if(a[i]<=cnt) break;
if(i==1) cnt++;
}
cout<<cnt-1<<endl;
return 0;
}