n=int(eval(input()))

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



a.sort()

amax=a[-1]

amin=a[0]



s=[]

ai=a[0]

acnt=-1

for i in range(n):

    if a[i]>ai:

        s.append([ai,acnt+1])

        acnt=0

        ai=a[i]

    else:

        acnt=acnt+1

s.append([ai,acnt+1])

        

# print(s)

    

dn=0

for i in range(len(s)):

    ni=s[i][1]

    if ni>s[i][0]:

        dn=dn+(ni-s[i][0])

    elif ni<s[i][0]:

        dn=dn+ni



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

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



d=dict()



for i in range(n):

    if a[i] in d:

        d[a[i]]=d[a[i]]+1

    else:

        d[a[i]]=1

        

xsum=0

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

    if d[x]<x:

        xsum=xsum+d[x]

    elif d[x]>x:

        xsum=xsum+d[x]-x

        

print(xsum)
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
amax = a[-1]
amin = a[0]
s = []
ai = a[0]
acnt = -1
for i in range(n):
    if a[i] > ai:
        s.append([ai, acnt + 1])
        acnt = 0
        ai = a[i]
    else:
        acnt = acnt + 1
s.append([ai, acnt + 1])
# print(s)
dn = 0
for i in range(len(s)):
    ni = s[i][1]
    if ni > s[i][0]:
        dn = dn + (ni - s[i][0])
    elif ni < s[i][0]:
        dn = dn + ni
print(dn)

n = int(eval(input()))
a = list(map(int, input().split()))
d = dict()
for i in range(n):
    if a[i] in d:
        d[a[i]] = d[a[i]] + 1
    else:
        d[a[i]] = 1
xsum = 0
for x in list(d.keys()):
    if d[x] < x:
        xsum = xsum + d[x]
    elif d[x] > x:
        xsum = xsum + d[x] - x
print(xsum)

-a.sort() -amax = a[-1] -amin = a[0] -s = [] -ai = a[0] -acnt = -1 +d = dict() -    if a[i] > ai: -        s.append([ai, acnt + 1]) -        acnt = 0 -        ai = a[i] +    if a[i] in d: +        d[a[i]] = d[a[i]] + 1 -        acnt = acnt + 1 -s.append([ai, acnt + 1]) -# print(s) -dn = 0 -for i in range(len(s)): -    ni = s[i][1] -    if ni > s[i][0]: -        dn = dn + (ni - s[i][0]) -    elif ni < s[i][0]: -        dn = dn + ni -print(dn) +        d[a[i]] = 1 +xsum = 0 +for x in list(d.keys()): +    if d[x] < x: +        xsum = xsum + d[x] +    elif d[x] > x: +        xsum = xsum + d[x] - x +print(xsum)