n = int(input()) s = [int(i) for i in input().split()] s.sort() flag = 0 for i in range(n,0,-1): if s[n - i] > i: flag = 1 print(i) break if 1 - flag: print(0)