n = gets.to_i
arr = Array.new(101, 0)
gets.chomp.split.map(&:to_i).each{|x| arr[x] += 1}
99.downto(0){|i| arr[i] += arr[i + 1]}
100.downto(1){|i|
    if arr[i] >= i
        puts i
        break
    end
}
