#include <bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(0),cin.tie(0);
int N,n;
int v[200000+5] = {0};
while (cin>>N){
memset(v,0,N+5);
for (int i=0 ; i<N ; i++){
cin>>n;
v[1] += 1;
v[n+1] -= 1;
}
for (int i=2 ; i<=N ; i++) v[i]+=v[i-1];
for (int i=N ; i>0 ; i--){
if (v[i] >= i){
cout<<i<<"\n";
break;
}
}
}
}