#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

int main(void){
	int n;
	cin >> n;
	int p[n];
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	sort(p, p+n, greater<int>());
	int count = 0;
	for(int i = 0; i < n; i++){
		if(i >= p[i]) break;
		count++;
	}
	cout << count << endl;

}

