n = int(eval(input()))

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

a.sort()

count = 1

ans = 0

for i in range(1,n):

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

        if a[i-1] < count:

            ans += count - a[i-1]

        elif a[i-1] > count:

            ans += count

        count = 1

    else:

        count+=1

if a[n-1] < count:

    ans += count - a[n-1]

elif a[n-1] > count:

    ans += count

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

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

a.sort()

count = 1

ans = 0

for i in range(n-1):

    if a[i+1] != a[i]:

        if count >= a[i]:

            ans += count-a[i]

        else:

            ans += count

        count = 1

    else:

        count+=1

if count >= a[-1]:

    ans += count-a[-1]

else:

    ans += count

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
count = 1
ans = 0
for i in range(1, n):
    if a[i] != a[i - 1]:
        if a[i - 1] < count:
            ans += count - a[i - 1]
        elif a[i - 1] > count:
            ans += count
        count = 1
    else:
        count += 1
if a[n - 1] < count:
    ans += count - a[n - 1]
elif a[n - 1] > count:
    ans += count
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
count = 1
ans = 0
for i in range(n - 1):
    if a[i + 1] != a[i]:
        if count >= a[i]:
            ans += count - a[i]
        else:
            ans += count
        count = 1
    else:
        count += 1
if count >= a[-1]:
    ans += count - a[-1]
else:
    ans += count
print(ans)

-for i in range(1, n): -    if a[i] != a[i - 1]: -        if a[i - 1] < count: -            ans += count - a[i - 1] -        elif a[i - 1] > count: +for i in range(n - 1): +    if a[i + 1] != a[i]: +        if count >= a[i]: +            ans += count - a[i] +        else: -if a[n - 1] < count: -    ans += count - a[n - 1] -elif a[n - 1] > count: +if count >= a[-1]: +    ans += count - a[-1] +else: