#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,data[101];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&data[i]);
  }

  int cnt1,cnt2;
  cnt1 = 0;
  while(1){
    cnt2 = 0;
    for(int i=0;i<n;i++){
      if(data[i] >= cnt1){
	cnt2++;
      }
    }
    if(cnt2 < cnt1) break; 
    cnt1++;
  }
  
  cout << cnt1-1 << endl;

  return 0;
}