import collections



N=int(eval(input()))

List=sorted(list(map(int, input().split())))



c = collections.Counter(List) #要素と出現回数の辞書

value, count = list(zip(*c.most_common()))





newList=[]



for i in range(len(value)):

    if N-len(newList)>=value[i] and count[i]>=value[i]:

        for j in range(value[i]):

            newList.append(value[i])

    else:

        continue



#print(newList)



Ans=len(List)-len(newList)

print(Ans)
import collections



N = int(eval(input()))

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



c = collections.Counter(A) #要素と出現回数の辞書

#print(c)



ans = 0

for k,v in list(c.items()):

    ans += v if v<k else v-k

print(ans)
import collections

N = int(eval(input()))
List = sorted(list(map(int, input().split())))
c = collections.Counter(List)  # 要素と出現回数の辞書
value, count = list(zip(*c.most_common()))
newList = []
for i in range(len(value)):
    if N - len(newList) >= value[i] and count[i] >= value[i]:
        for j in range(value[i]):
            newList.append(value[i])
    else:
        continue
# print(newList)
Ans = len(List) - len(newList)
print(Ans)

import collections

N = int(eval(input()))
A = list(map(int, input().split()))
c = collections.Counter(A)  # 要素と出現回数の辞書
# print(c)
ans = 0
for k, v in list(c.items()):
    ans += v if v < k else v - k
print(ans)

-List = sorted(list(map(int, input().split()))) -c = collections.Counter(List)  # 要素と出現回数の辞書 -value, count = list(zip(*c.most_common())) -newList = [] -for i in range(len(value)): -    if N - len(newList) >= value[i] and count[i] >= value[i]: -        for j in range(value[i]): -            newList.append(value[i]) -    else: -        continue -# print(newList) -Ans = len(List) - len(newList) -print(Ans) +A = list(map(int, input().split())) +c = collections.Counter(A)  # 要素と出現回数の辞書 +# print(c) +ans = 0 +for k, v in list(c.items()): +    ans += v if v < k else v - k +print(ans)