//二分
#include <iostream>
using namespace std;
const int N = 100010;
int n;
int w[N];
bool check(int x){
int a = 0;
for(int i=0;i<n;i++){
if(w[i] >= x)
a++;
}
return a >= x;
}
int main(){
cin >> n;
for(int i=0;i<n;i++){
cin >> w[i];
}
int l=0,r=n;
while(l<r){
int mid = (l + r + 1) >> 1;
if(check(mid)){
l = mid;
}else{
r = mid-1;
}
}
cout << r << endl;
return 0;
}
感觉不如....牛的学术圈1