N=int(eval(input()))

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

A.sort()

from collections import Counter

A=Counter(A)

ret=0

for i in A.most_common():

  if i[0]>i[1]:

    ret+=i[1]

  else:

    ret+=i[1]-i[0]

print(ret)
N=int(eval(input()))

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

from collections import Counter

A=Counter(A)

ret=0

for i in A.most_common():

  if i[0]>i[1]:

    ret+=i[1]

  else:

    ret+=i[1]-i[0]

print(ret)
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
from collections import Counter

A = Counter(A)
ret = 0
for i in A.most_common():
    if i[0] > i[1]:
        ret += i[1]
    else:
        ret += i[1] - i[0]
print(ret)

N = int(eval(input()))
A = list(map(int, input().split()))
from collections import Counter

A = Counter(A)
ret = 0
for i in A.most_common():
    if i[0] > i[1]:
        ret += i[1]
    else:
        ret += i[1] - i[0]
print(ret)

-A.sort()