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

int main(){
    int n;
    cin >> n;
    vector<int> score(n);

    for( int i = 0; i < n; i++ ){
        cin >> score[i];
    }
    
    int t_score = 0;
    for( int i = 1; i <= n; i++ ){
        int j = 0;
        int count = 0;
        for( ;j < n; j++ ){
            if( score[j] >= i ){
                count++;
            }
        }
        if( count >= i ){
            t_score = i;
        }
    }
    
    cout << t_score << endl;
}
