from itertools import takewhile as T



N = int(eval(input()))

p = list(map(int, input().split()))

score = [0] * 101

for x in p:

    score[x] += 1



print((len(list(T(lambda i: sum(score[i:]) >= i, list(range(1, 101)))))))
N = int(eval(input()))

p = list(map(int, input().split()))

score = [0] * 101

for x in p:

    score[x] += 1

    

i = 1

while sum(score[i:]) >= i:

    i += 1

print((i-1))
from itertools import takewhile as T

N = int(eval(input()))
p = list(map(int, input().split()))
score = [0] * 101
for x in p:
    score[x] += 1
print((len(list(T(lambda i: sum(score[i:]) >= i, list(range(1, 101)))))))

N = int(eval(input()))
p = list(map(int, input().split()))
score = [0] * 101
for x in p:
    score[x] += 1
i = 1
while sum(score[i:]) >= i:
    i += 1
print((i - 1))

-from itertools import takewhile as T - -print((len(list(T(lambda i: sum(score[i:]) >= i, list(range(1, 101))))))) +i = 1 +while sum(score[i:]) >= i: +    i += 1 +print((i - 1))