#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct pol{
	int X;int Y;int Z;
  bool operator<(const pol&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
int main(){
	int N;
	int P[100];
	cin>>N;
	FOR(i,0,N){
		cin>>P[i];
	}
	sort(P,P+N);
	int now=P[N-1];
	while(1){
		if(N-(lower_bound(P,P+N,now)-P)>=now){
			cout<<now<<endl;
			break;
		}else{
			now--;
		}
	}
	return 0;
}

