N = eval(input())

A = sorted([int(x) for x in input().split()])

import bisect as bs

ans = 0

f = lambda X, x: bs.bisect_right(X,x) - bs.bisect_left(X,x)

for a in set(A):

    cnt = f(A,a)

    if cnt < a:

        ans += cnt

    else:

        ans += cnt-a

print(ans)
from collections import Counter

from itertools import starmap

def main():

    N = eval(input())

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

    count = Counter(A)

    remove = lambda x,y: y-x if y >= x else y

    ans = sum(starmap(remove, list(count.items())))

    print(ans)



main()
N = eval(input())
A = sorted([int(x) for x in input().split()])
import bisect as bs

ans = 0
f = lambda X, x: bs.bisect_right(X, x) - bs.bisect_left(X, x)
for a in set(A):
    cnt = f(A, a)
    if cnt < a:
        ans += cnt
    else:
        ans += cnt - a
print(ans)

from collections import Counter
from itertools import starmap


def main():
    N = eval(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    remove = lambda x, y: y - x if y >= x else y
    ans = sum(starmap(remove, list(count.items())))
    print(ans)


main()

-N = eval(input()) -A = sorted([int(x) for x in input().split()]) -import bisect as bs +from collections import Counter +from itertools import starmap -ans = 0 -f = lambda X, x: bs.bisect_right(X, x) - bs.bisect_left(X, x) -for a in set(A): -    cnt = f(A, a) -    if cnt < a: -        ans += cnt -    else: -        ans += cnt - a -print(ans) + +def main(): +    N = eval(input()) +    A = list(map(int, input().split())) +    count = Counter(A) +    remove = lambda x, y: y - x if y >= x else y +    ans = sum(starmap(remove, list(count.items()))) +    print(ans) + + +main()