n=int(eval(input()))

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

b=set()

ans=0

d={}

cnt=0

for i in range(n):

    if i!=0 and a[i]!=a[i-1]:

        d[a[i-1]]=cnt

        cnt=0

    cnt+=1

    if i==n-1:

        x=a.count(a[i])

        d[a[i]]=x

for i in list(d.keys()):

    if d[i]>=i:

        ans+=d[i]-i

    else:

        ans+=d[i]

print(ans)
n=int(eval(input()))

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

from collections import Counter

c=Counter(a)

ans=0

for x,y in list(c.items()):

    if x<=y:

        ans+=y-x

    else:

        ans+=y

print(ans)
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = set()
ans = 0
d = {}
cnt = 0
for i in range(n):
    if i != 0 and a[i] != a[i - 1]:
        d[a[i - 1]] = cnt
        cnt = 0
    cnt += 1
    if i == n - 1:
        x = a.count(a[i])
        d[a[i]] = x
for i in list(d.keys()):
    if d[i] >= i:
        ans += d[i] - i
    else:
        ans += d[i]
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
from collections import Counter

c = Counter(a)
ans = 0
for x, y in list(c.items()):
    if x <= y:
        ans += y - x
    else:
        ans += y
print(ans)

-a = sorted(list(map(int, input().split()))) -b = set() +a = list(map(int, input().split())) +from collections import Counter + +c = Counter(a) -d = {} -cnt = 0 -for i in range(n): -    if i != 0 and a[i] != a[i - 1]: -        d[a[i - 1]] = cnt -        cnt = 0 -    cnt += 1 -    if i == n - 1: -        x = a.count(a[i]) -        d[a[i]] = x -for i in list(d.keys()): -    if d[i] >= i: -        ans += d[i] - i +for x, y in list(c.items()): +    if x <= y: +        ans += y - x -        ans += d[i] +        ans += y