#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a, s[101];
  ll result = 0;
  rep(i, 101) s[i] = 0;
  cin >> n;
  rep(i, n) {
    cin >> a;
    FOR(j, 1, a + 1) s[j]++;
  }
  FOR(i, 1, 101) {
    if(s[i] >= i) result = i;
  }
  cout << result << endl;
	return 0;
}
