n = int(eval(input()))

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

n = len(a)

a.sort()

a.append(-1)

ans = 0

i = 0

while i < n:

    cnt = 1

    while a[i] == a[i+1]:

        cnt += 1

        i += 1

        if i == len(a)-1:

            break

    if cnt > a[i]:

        ans += cnt - a[i]

    elif cnt < a[i]:

        ans += cnt

    i += 1

print(ans)
from collections import Counter

n = int(eval(input()))

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

c = Counter(a)

ans = 0

for val, cnt in c.most_common():

    if val > cnt:

        ans += cnt

    elif val < cnt:

        ans += cnt - val

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
n = len(a)
a.sort()
a.append(-1)
ans = 0
i = 0
while i < n:
    cnt = 1
    while a[i] == a[i + 1]:
        cnt += 1
        i += 1
        if i == len(a) - 1:
            break
    if cnt > a[i]:
        ans += cnt - a[i]
    elif cnt < a[i]:
        ans += cnt
    i += 1
print(ans)

from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for val, cnt in c.most_common():
    if val > cnt:
        ans += cnt
    elif val < cnt:
        ans += cnt - val
print(ans)

+from collections import Counter + -n = len(a) -a.sort() -a.append(-1) +c = Counter(a) -i = 0 -while i < n: -    cnt = 1 -    while a[i] == a[i + 1]: -        cnt += 1 -        i += 1 -        if i == len(a) - 1: -            break -    if cnt > a[i]: -        ans += cnt - a[i] -    elif cnt < a[i]: +for val, cnt in c.most_common(): +    if val > cnt: -    i += 1 +    elif val < cnt: +        ans += cnt - val