#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(int &a, int &b){
return a > b;
}
int main()
{
int n;
cin >> n;
vector<int> v(n);
for(int i = 0; i < n; i++){
cin >> v[i];
}
sort(v.begin(), v.end(), cmp);
int cnt = 1;
for (int i = 0; i < n; i++){
if(v[i] > cnt) cnt++;
else break;
}
cout << cnt - 1 << endl;
return 0;
}