CodeEff/ECCO huggingface dataset:
# Original solution
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    a,b = LI()
    print((math.ceil((a+b)/2)))

#B
def B():
    s = S()
    t = S()
    s.sort()
    t.sort()
    t = t[::-1]
    l = [s,t]
    l.sort()
    if s == t:
        print("No")
    elif l[0] == s:
        print("Yes")
    else:
        print("No")
#C
def C():
    n = I()
    d = defaultdict(int)
    a = LI()
    for i in a:
        d[i] += 1
    ans = 0
    for i in list(d.keys()):
        if i <= d[i]:
            ans += d[i]-i
        else:
            ans += d[i]
    print(ans)
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


# Optimized solution
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    d = defaultdict(lambda : 0)
    for i in a:
        d[i] += 1
    ans = 0
    for i in set(a):
        if d[i] < i:
            ans += d[i]
        else:
            ans += d[i]-i
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()
# Original solution
from collections import Counter

N = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)

ans = 0
for key in c:
  if c[key] >= key:
    ans += (c[key] - key)
  else:
    ans += c[key]
print(ans)

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))

d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
  
ans = 0
for key in d:
  if d[key] >= key:
    ans += (d[key] - key)
  else:
    ans += d[key]
print(ans)
# Original solution
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()
a_lis = list(set(a))
count = 0
ans = [0]*len(a_lis)
for i in range(len(a_lis)):
    count = a.count(a_lis[i])
    if count > a_lis[i]:
        ans[i] = count - a_lis[i]
    elif count < a_lis[i]:
        ans[i] = count

if sum(ans) < n:
    print((sum(ans)))
else:
    print(n)


# Optimized solution
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()

dic = {}

for num in a:
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

ans = 0
for key,value in list(dic.items()):
    if key > value:
        ans += value
    else:
        ans += (value - key)

print(ans)
# Original solution
n = int(eval(input()))
a = tuple(map(int, input().split(" ")))

sum_num = 0
for a_i in set(a):
	a_count_a_i  = a.count(a_i)
	sum_num += a_count_a_i - a_i if a_i <= a_count_a_i else a_count_a_i
print(sum_num)

# Optimized solution
n = int(eval(input()))
a = tuple(map(int, input().split(" ")))

a_count = dict()
for a_i in a:
	if a_i not in a_count:
		a_count[a_i] = 0 
	a_count[a_i] += 1

sum_num = 0
for a_i in a_count:
	a_count_a_i = a_count[a_i]
	sum_num += a_count_a_i - a_i if a_i <= a_count_a_i else a_count_a_i
print(sum_num)
# Original solution
from collections import Counter

N = int(eval(input()))
A = [int(i) for i in input().split()]

ans = 0
for k, v in list(Counter(A).items()):
    if k > v:
        ans += v
    else:
        ans += v - k
print(ans)

# Optimized solution
from collections import *
eval(input())
print((sum(v if k>v else v-k for k,v in list(Counter(list(map(int,input().split()))).items()))))
# Original solution
from collections import defaultdict
N = int(eval(input()))
A = [int(i) for i in input().split()]
D = defaultdict(int)

for i in range(N):
    D[A[i]] += 1

delete = 0
for d in D:
    if d < D[d]:
        delete += D[d] - d
    elif d > D[d]:
        delete += D[d]
print(delete)


# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    AD = dict()
    for a in A:
        if a in AD: AD[a] += 1
        else: AD[a] = 1

    count = 0
    for key in AD:
        if AD[key] == key: continue
        elif AD[key] > key: count += AD[key] - key
        else: count += AD[key]
    print(count)

    return 0

if __name__ == "__main__":
    solve()
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
s = set(a)

ans = 0
for i in s:
    c = a.count(i)
    if c < i:
        ans += c
    elif c >= i:
        ans += c - i
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
s = set(a)

d = {}
for i in s:
    d[i] = 0
for i in a:
    d[i] += 1

ans = 0
for i in d:
    c = d[i]
    if c < i:
        ans += c
    elif c >= i:
        ans += c - i
print(ans)
# Original solution
N = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
b = list(set(a))
cnt = 0
for i in range(len(b)):
  c = a.count(b[i])
  if b[i] <= c:
    cnt += c - b[i]
  else:
    cnt += c
print(cnt)

# Optimized solution
N = int(eval(input()))
a = list(map(int,input().split()))
a.sort(reverse = True)
b = list(set(a))
ans = 0
for i in range(len(b)):
  cnt = 1
  while len(a) > 1 and a[-1] == a[-2]:
    a.pop()
    cnt += 1
  c = a.pop()
  if c <= cnt:
    ans += cnt - c
  else:
    ans += cnt
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
ans = 0
b = 0
for i in range(N):
    if i == b:
        a = A.count(A[i])
        b = i + a
        if A[i] > a:
            ans += a
        elif A[i] < a:
            ans += a - A[i]
print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
old = A[0]
a = 1
ans = 0
for i in range(1, N):
    cur = A[i]
    if cur == old:
        a += 1
    else:
        if old <= a:
            ans += a - old
        else:
            ans += a
        a = 1
    old = cur
if old <= a:
    ans += a - old
else:
    ans += a
print(ans)
# Original solution
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X = ii()
    A = collections.Counter(il())

    ret = 0
    for k, v in list(A.items()):
        if k > v:
            ret += v
        if k < v:
            ret += abs(k-v)
    print(ret)


if __name__ == '__main__':
    main()


# Optimized solution
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = collections.Counter(il())

    ret = 0
    for k in A:
        v = A[k]
        if k <= v:
            ret += abs(k-v)
        else:
            ret += v
    print(ret)


if __name__ == '__main__':
    main()
# Original solution
import sys
import collections
input=sys.stdin.readline

n=int(eval(input()))
l=list(map(int,input().split()))
li=collections.Counter(l)
#print(li)
a=0
for k,v in list(li.items()):
    if k>v:
        a+=v
    else:
        a+=v-k
print(a)

# Optimized solution
import sys
import collections
input=sys.stdin.readline

n=int(eval(input()))
l=list(map(int,input().split()))
s=collections.Counter(l)
#print(s)
a=0
for k,v in list(s.items()):
    if k>v:
        a+=v
    else:
        a+=v-k
print(a)
# Original solution
import collections
N=int(eval(input()))
A=list(map(int,input().split()))
C=collections.Counter(A)
ans=0
for i,j in list(C.items()):
  if i!=j:
    a=j-i if j>=i else j
    ans+=a
print(ans)

# Optimized solution
import collections
N=int(eval(input()))
A=list(map(int,input().split()))
C=collections.Counter(A)
ans=0
for i,j in list(C.items()):
    a=j-i if j>=i else j
    ans+=a
print(ans)
# Original solution
# -*- coding: utf-8 -*-

#https://atcoder.jp/contests/abc082/tasks/abc082_c
length = int(eval(input()))
a = [int(i) for i in input().split()]

count = 0
for i in range(length):
	if(i+1 <= a.count(i+1)):
		count += i+1
print((length - count))

# Optimized solution
# -*- coding: utf-8 -*-

#https://atcoder.jp/contests/abc082/tasks/abc082_c
length = int(eval(input()))
a = [int(i) for i in input().split()]
set_a = set(a)

count = 0
for i in set(a):
	if (i > length):
		continue
	if(i <= a.count(i)):
		count += i
print((length - count))
# Original solution
# coding: utf-8
# Your code here!
import collections
N=int(eval(input()))
A=list(map(int,input().split()))
c = collections.Counter(A)
ans=0
n=len(set(A))
for i in range(n):
    a=int(c.most_common()[i][0])
    b=c.most_common()[i][1]
    if a <= b:
        ans+=b-a
    else:
        ans+=b
print(ans)

# Optimized solution
import collections
N=int(eval(input()))
A=list(map(int,input().split()))
c = collections.Counter(A)
ans=0
n=len(set(A))
c_=c.most_common()
for i in range(n):
    a=int(c_[i][0])
    b=c_[i][1]
    if a <= b:
        ans+=b-a
    else:
        ans+=b
print(ans)
# Original solution
import collections
N=int(eval(input()))
A=list(map(int,input().split()))
c = collections.Counter(A)
ans=0
n=len(set(A))
c_=c.most_common()
for i in range(n):
    a=int(c_[i][0])
    b=c_[i][1]
    if a <= b:
        ans+=b-a
    else:
        ans+=b
print(ans)

# Optimized solution
# coding: utf-8
import collections
N = int(eval(input()))
A=  list(map(int,input().split()))

A.sort()

c = collections.Counter(A)
A_ = list(set(A))
ans = 0
for a in A_:
    #print(c[a],a)
    if a > c[a]:
        ans += c[a]
    else:
        ans += c[a]-a
    
print(ans)
# Original solution
import collections

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

c = collections.Counter(A)

ans = 0
for i in set(A):
    if i > c[i]:
        ans += c[i]
    if i < c[i]:
        ans += (c[i] -i)
print(ans)

# Optimized solution
from collections import Counter

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

c = Counter(a)

ans = 0
for k, v in list(c.items()):
    if k > v:
        ans += v
    else:
        ans += (v-k)

print(ans)
# Original solution
#coding:utf-8
from collections import Counter
n = int(eval(input()))
A = list(map(int,input().split()))
c = Counter(A)
ans = 0
for i in list(c.items()):
    if i[1]>=i[0]:
        ans += i[1]-i[0]
    else:
        ans += i[1]
print (ans)

# Optimized solution
#coding:utf-8
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
c = Counter(A)
ans = 0
for it in list(c.items()):
    if it[0] <= it[1]:
        ans += (it[1]-it[0])
    else:
        ans += it[1]
print (ans)
# Original solution
from collections import Counter
n=int(eval(input()))
nums=input().split()
counter=Counter(nums).most_common()
k=0
for num, c in counter:
    num=int(num)
    if num==c:
        continue
    elif num>c:
        for v in range(c):
            nums.remove(str(num))
            k+=1
    else:
        for v in range(c-num):
            nums.remove(str(num))
            k+=1   

print(k)

# Optimized solution
from collections import Counter
n=int(eval(input()))
counter=Counter(list(map(int,input().split())))
print((sum(c-num if c>=num else c for num,c in list(counter.items()))))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=set(a)
ans=0
for i in b:
    if a.count(i)-i>=0:
        ans+=a.count(i)-i
    else:
        ans+=a.count(i)
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i,c in list(count.items()):
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)
# Original solution
N = int(eval(input()))
#put a_i into list
list_a_i = list(sorted(map(int, input().split())))
remove = 0
while len(list_a_i) >=1:
    #count number of list_a_i[1]
    x = list_a_i.count(list_a_i[0])
    if x > list_a_i[0]:
        remove += x - list_a_i[0]
    elif x < list_a_i[0]:
        remove += x
    for i in range(x):
        list_a_i.remove(int(list_a_i[0]))
print(remove)


# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
dic = {}
for elem in a:
    if elem not in dic:
        dic[elem] = 1
    else:
        dic[elem] += 1

ans = 0
for k in list(dic.keys()):
    if dic[k] > k:
        ans += dic[k] - k
    elif dic[k] < k:
        ans += dic[k]

print(ans)
# Original solution
from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
cnt = 0
for i in range(len(a)):
    k,v=a.most_common()[i][0],a.most_common()[i][1]
    if v-k < 0:
        cnt += v
    else:
        cnt += v-k
print(cnt)


# Optimized solution
from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
cnt = 0
for k, v in list(Counter(a).items()):
    if k > v:
        cnt += v
    else:
        cnt += (v-k)
print(cnt)
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
c = 0
for i in set(A):
  if A.count(i) >= i:
    c += A.count(i)-i
  else:
    c += A.count(i)
print(c)


# Optimized solution
import bisect

n = int(eval(input()))
A = sorted(list(map(int, input().split())))
c = 0
temp = 0
for i in sorted(list(set(A))):
  d = bisect.bisect_right(A, i)
  if d-temp >= i:
    c += d-temp - i
  else:
    c += d-temp
  temp = d
print(c)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
B = (10**5+1)*[0]
ans = 0

for a in A:
  if a<=10**5:
    B[a]+=1
  else:
    ans+=1

for n in range(10**5):
  if B[n]<n:
    ans+=B[n]
  elif n<B[n]:
    ans+=B[n]-n

print(ans)

# Optimized solution
from collections import *
N = int(eval(input()))
C = Counter(list(map(int,input().split())))
ans = 0

for k,v in list(C.items()):
  if k<v:
    ans+=v-k
  elif v<k:
    ans+=v

print(ans)
# Original solution
from collections import Counter
N = int(eval(input()))
src = list(map(int,input().split()))
ctr = Counter(src)

ans = 0
for k,v in list(ctr.items()):
    if k < v:
        ans += v-k
    elif k > v:
        ans += v
print(ans)


# Optimized solution
from collections import Counter
N = int(eval(input()))
src = list(map(int,input().split()))
ctr = Counter(src)
ans = 0
for k,v in list(ctr.items()):
    ans += v if v<k else v-k
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

aset = set(a)

ans = 0

for i in aset:
    if a.count(i) < i:
        ans += a.count(i)
    else:
        ans += a.count(i) - i

print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

d = dict()
for i in a:
    d[i] = d.get(i, 0) + 1


ans = 0
for i in list(d.items()):
    if i[0] > i[1]:
        ans += i[1]
    elif i[0] < i[1]:
        ans += i[1] - i[0]

print(ans)
# Original solution
N = int(eval(input()))
S = list(int(i) for i in input().split())  
list = []
count = 0

for i in range(N):
    if S[i] not in list:
        num = S[i:].count(S[i])
        if num < S[i]:
            count += num
        elif num > S[i]:
            count += (num-S[i])
    list.append(S[i])

print(count)

# Optimized solution
N = int(eval(input()))
S = list(int(i) for i in input().split())  
dict = {}
count = 0

for i in range(N):
    if S[i] not in dict:
        dict[S[i]] = 1
    else:
        dict[S[i]] += 1

for key, value in list(dict.items()):
    if key < value:
        count += (value-key)
    elif key > value:
        count += value

print(count)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))

b=set(a)
ans =0
for i in b:
    c=a.count(i)
    if c>i:
        ans +=  c-i
    elif c<i:
        ans += c
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a=sorted(a)
a.append(-1)

count=1
ans=0

for i in range(0,n):
    if a[i+1]==a[i]:
        count += 1
    else:

        if count > a[i]:
            ans += count - a[i]
        elif count < a[i]:
            ans += count

        count = 1

print(ans)
# Original solution
from collections import Counter 
n = int(eval(input()))
l = list(map(int, input().split()))
c = Counter(l)
ans = 0
for k, v in list(c.items()):
    if k < v:
        ans += v - k
    elif k > v:
        ans += v
print(ans)

# Optimized solution
from collections import Counter
N = int(eval(input()))
a = list(map(int, input().split()))
ca = Counter(a)
ans = 0
for k, v in list(ca.items()):
    if v < k:
        ans += v
    elif v > k:
        ans += v-k
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

b = list(set(a))
m = len(b)

ans = 0
for i in range(m):
    c = a.count(b[i])
    if b[i] > c: ans += c
    if b[i] < c: ans += c - b[i]

print(ans) 


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

b = [0 for _ in range(n+1)]

ans = 0
for i in range(n):
    if a[i] > n:
        ans += 1
    else:
        b[a[i]] += 1 

for i in range(n+1):
    if b[i] > i: ans += b[i] - i
    if b[i] < i: ans += b[i]

print(ans)
# Original solution
from collections import Counter
a = int(eval(input()))
l = list(map(int, input().split()))
#i = 1

c=Counter(l)
d = dict(c)
kv = []
for k,v in list(d.items()):
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
cnt = [0] * n + [0]
for i in a:
  if i > n:
    ans += 1
  else:
    cnt[i] += 1
for i in range(n + 1):
  ans += cnt[i] - i if cnt[i] >= i else cnt[i]
print(ans)
# Original solution
from collections import Counter
from collections import deque

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

# Optimized solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for num, cnt in list(c.items()):
    if cnt>=num:
        ans += cnt - num
    else:
        ans += cnt
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
T = list(set(A))
L = []
for i in range(len(T)) :
    ti = T[i]
    t = A.count(ti)
    if t < ti :
        L.append(t)
    else :
        L.append(t - ti) 
print((sum(L)))


# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
D = {}
for i in A :
    if i in D :
        D[i] += 1
    else :
        D[i] = 1
answer = 0
for key, value in list(D.items()) :
    if key > value :
        answer += value
    else :
        answer += value-key
print(answer)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
cnt = 0
ind = 1
while A != []:
  A = list([x - 1 for x in A])
  if(0 in A):
    zero = A.count(0)
    if(zero > ind):
      cnt += abs(zero - ind)
    elif(zero < ind):
      cnt += zero
    A = [n for n in A if n != 0]
  ind += 1
print(cnt)

# Optimized solution
N = int(eval(input()))
a = list(map(int,input().split()))

d = {}
for i in range(N):
  if(a[i] not in d):
    d[a[i]] = 1
  else:
    d[a[i]] += 1
cnt = 0
for k, v in list(d.items()):
  if(k > v):
    cnt += v
  elif(k < v):
    cnt += v - k
print(cnt)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))

ans = 0
c19 = 0
for i in range(1,100001):
    ca = a.count(i)
    if ca >= i:
        ans += ca - i
    else:
        ans += ca
    c19 += ca
print((ans + n-c19))

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
d = {}
count = 0
for i in range(n):
    if not a[i] in list(d.keys()) and (n-count)>=a[i]:
        ac = a.count(a[i])
        d.update({a[i]:ac})
        count += ac
ans = 0
for i in sorted(d.keys()):
    if i <= d[i]:
        ans += d[i]-i
    else:
        ans += d[i]

print((ans + n-count))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
c_num = set(a)
c_num = list(c_num)
c_cnt = [0]*(len(c_num))

for i in a:
    index = c_num.index(i)
    c_cnt[index] += 1

for i, x in enumerate(c_num):
    c_cnt[i] -= x

ans = 0

for i, x in zip(c_num, c_cnt):
    if x > 0:
        ans += x
    elif x < 0:
        ans += i + x

print(ans)

# Optimized solution
def count(list):
    dict = {}
    for i in range(len(list)):
        dict[list[i]] = dict.get(list[i], 0) + 1
    return dict

n = int(eval(input()))
a = list(map(int,input().split()))
dic = count(a)
ans = 0

for i, x in list(dic.items()):
    differ = x - i
    if differ>0:
        ans += differ
    elif differ<0:
        ans += x

print(ans)
# Original solution
N = int(eval(input()))
a = input().split()
a_n = [int(s) for s in a]

list = []
for x in a_n:
    if list == []:
        list.append([x,1])
    else:
        counter = 0
        for y in list:
            if y[0] == x:
                y[1] += 1
                counter = 1220
        if counter == 0:
            list.append([x,1])

counter = 0
for y in list:
    if y[0] > y[1]:
        counter += y[1]
    elif y[0] < y[1]:
        counter += y[1] - y[0]
print(counter)

# Optimized solution
N = int(eval(input()))
a = input().split()
a_n = [int(s) for s in a]

dict = {}
for i in range(N):
    if a_n[i] in dict:
        dict[a_n[i]] += 1
    else:
        dict[a_n[i]] = 1

cnt = 0
for i in dict:
    if dict[i] > i:
        cnt += dict[i] - i
    elif dict[i] < i:
        cnt += dict[i]
print(cnt)
# Original solution
N = int(eval(input()))
A_LI = sorted(map(int, input().split()))
A_SET = set(A_LI)
ans = 0
for a in A_SET:
    cnt = A_LI.count(a)
    if cnt < a:
        ans += cnt
    else:
        ans += cnt - a
print(ans)


# Optimized solution
N = int(eval(input()))
A_LI = sorted(map(int, input().split()))
a_dict = {}
ans = 0
pre = None
for a in A_LI:
    if a not in a_dict:
        if pre in a_dict:
            # 出揃った値について取り除く個数を求める
            if a_dict[pre] < pre:
                ans += a_dict[pre]
            else:
                ans += a_dict[pre] - pre
        pre = a
        a_dict[a] = 1
    else:
        a_dict[a] += 1
# 最後の値について取り除く個数を求める
if a_dict[pre] < pre:
    ans += a_dict[pre]
else:
    ans += a_dict[pre] - pre
print(ans)