#include <bits/stdc++.h>

using namespace std;
using i64 = int64_t;

signed main(){
    
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    auto f = [&](int val){
        int cnt = 0;
        for(auto& x : a)
            cnt += (x >= val);
        return cnt >= val;
    };
    int ok = 0;
    int ng = 1000;
    while(ng - ok > 1){
        int mid = (ng + ok) >> 1;
        (f(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
    
    
    return 0;
}
