N=int(eval(input()))

a=[0 for i in range(N)]

st=input().split()

for i in range(N):

    a[i]=int(st[i])

aa=sorted(a)

count=0

nowp=aa[0]

aa.append(10**9+1)

nowcount=1

for i in range(1,N+1):

    if aa[i-1]==aa[i]:

        nowcount+=1

    else:

        nowp=aa[i]

        if nowcount<aa[i-1]:

            count+=nowcount

        else:

            count+=nowcount-aa[i-1]

        nowcount=1

print(count)



N=int(eval(input()))

a=[int(i) for i in input().split()]

D=dict()

for i in range(N):

    if a[i] in D:

        D[a[i]]+=1

    else:

        D[a[i]]=1

ans=0

for num in D:

    if num<=D[num]:

        ans+=D[num]-num

    else:

        ans+=D[num]

print(ans)

N = int(eval(input()))
a = [0 for i in range(N)]
st = input().split()
for i in range(N):
    a[i] = int(st[i])
aa = sorted(a)
count = 0
nowp = aa[0]
aa.append(10**9 + 1)
nowcount = 1
for i in range(1, N + 1):
    if aa[i - 1] == aa[i]:
        nowcount += 1
    else:
        nowp = aa[i]
        if nowcount < aa[i - 1]:
            count += nowcount
        else:
            count += nowcount - aa[i - 1]
        nowcount = 1
print(count)

N = int(eval(input()))
a = [int(i) for i in input().split()]
D = dict()
for i in range(N):
    if a[i] in D:
        D[a[i]] += 1
    else:
        D[a[i]] = 1
ans = 0
for num in D:
    if num <= D[num]:
        ans += D[num] - num
    else:
        ans += D[num]
print(ans)

-a = [0 for i in range(N)] -st = input().split() +a = [int(i) for i in input().split()] +D = dict() -    a[i] = int(st[i]) -aa = sorted(a) -count = 0 -nowp = aa[0] -aa.append(10**9 + 1) -nowcount = 1 -for i in range(1, N + 1): -    if aa[i - 1] == aa[i]: -        nowcount += 1 +    if a[i] in D: +        D[a[i]] += 1 -        nowp = aa[i] -        if nowcount < aa[i - 1]: -            count += nowcount -        else: -            count += nowcount - aa[i - 1] -        nowcount = 1 -print(count) +        D[a[i]] = 1 +ans = 0 +for num in D: +    if num <= D[num]: +        ans += D[num] - num +    else: +        ans += D[num] +print(ans)