CodeEff/ECCO huggingface dataset:
# Original solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))

count = Counter(a)

ans = 0
for i in list(count.items()):
  if i[1] < i[0]: ans += i[1]
  else: ans += abs(i[1]-i[0])
    
print(ans)

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

count = Counter(a)
ans = 0
for k,v in list(count.items()):
  if k < v: ans += v-k
  elif v < k: ans += v
print(ans)
# Original solution
import sys
N = int(eval(input()))

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

dic = {}
for ak in a:
    if not(ak in dic):
        dic[ak] = 1
    else:
        dic[ak] += 1
ans = 0
for k in list(dic.keys()):
    if(dic[k] - k > 0):
        ans+=dic[k] - k
    elif(dic[k] - k < 0):
        ans+=dic[k]
print(ans)


# Optimized solution
from sys import exit
import math
N = int(eval(input()))
dic = {}
a = [int(n) for n in input().split()]
for e in a:
    if e in dic:
        dic[e]+=1
    else:
        dic[e] = 1
ans = 0
for k in list(dic.keys()):
    if k < dic[k]:
        ans+=dic[k]-k
    elif k > dic[k]:
        ans+=dic[k]
    else:
        continue
print(ans)
# Original solution
N = int(eval(input()))
a = list(map(int,input().split()))

ans = 0
a_as = [0 for _ in range(max(a))]

for x in a:
    a_as[x-1] += 1

for i,cnt in enumerate(a_as):
    if cnt == 0 or cnt == i+1:
        continue
    elif cnt > i+1:
        ans += cnt - (i+1)
    else:
        ans += cnt
    
print(ans)

# Optimized solution

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

ans = 0
a_as = {}

for x in a:
    if x in a_as:
        a_as[x] += 1
    else:
        a_as[x] = 1

for x in a_as:
    if x > a_as[x]:
        ans += a_as[x]
    else:
        ans += abs(a_as[x]-x)
    
print(ans)
# Original solution
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)

ans = 0
for c in C:
    if c > C[c]:
        ans += C[c]
    elif c < C[c]:
        ans += C[c] - c
print(ans)

# Optimized solution
import sys
from collections import Counter
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)

ans = 0
for c in C:
    if c > C[c]:
        ans += C[c]
    elif c < C[c]:
        ans += C[c] - c
print(ans)
# Original solution
if __name__=="__main__":
    N = int(eval(input()))
    l = list(map(int,input().split(" ")))
    v = []
    c = []
    count = 0
    for i in l:
          if i not in v:
              v.append(i)
              c.append(1)
          else:
              c[v.index(i)]+=1
    for j in range(len(v)):
        count+= c[j]-v[j] if c[j]>=v[j] else c[j]
    print(count)

# Optimized solution
def main():
    N = int(eval(input()))
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in list(dic.items()):
        count += j[1] - j[0] if j[1] >= j[0] else j[1]
    print(count)


if __name__=="__main__":
    main()
# Original solution
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

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

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

    print(ans)


if __name__ == '__main__':
    main()


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


def main():
    from collections import Counter
    n = int(eval(input()))
    a = Counter(list(map(int, input().split())))
    ans = 0

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

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():

    n, *a = (int(x) for x in sys.stdin.read().split())
    c = collections.Counter(a)
    count = 0
    for i, j in list(c.items()):
        if j < i: count += j
        else: count += j - i
    
    print(count)
    
if __name__ == "__main__":
    # execute only if run as a script
    main()


# Optimized solution
import sys
from collections import Counter

n, *a = list(map(int, sys.stdin.read().split()))

def main():
    res = 0
    for v, c in list(Counter(a).items()):
        if c < v:
            res += c
        elif c > v:
            res += c - v
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
b = set(a)
ans = 0
for i in b:
  temp = a.count(i)
  if temp > i:
    ans += temp-i
  elif temp < i:
    ans += temp
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
b = []
c = {}
ans = 0
for i in range(n):
  if a[i] in c:
    c[a[i]] += 1
  else:
    c[a[i]] = 1
    b.append(a[i])
  
for i in range(len(b)):
  temp=c[b[i]]
  temp2=b[i] 
  if temp > temp2:
    ans += temp-temp2
  elif temp < temp2:
    ans += temp
  
  
print(ans)
# Original solution
from collections import Counter
N = int(eval(input()))
A = Counter(list(map(int,input().split()))).most_common()
S = 0
for i,c in A:
    if i == c:
        continue
    elif i > c:
        S += c
    else:
        S += c-i
print(S)


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

from collections import Counter
C = Counter(A).most_common()

ans = 0
for (k,v) in C:
    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))

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

# Optimized solution
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)
# Original solution
from collections import Counter

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

D = Counter(A)

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

print(res)

# Optimized solution
from collections import Counter

n = int(eval(input()))
A = list(map(int,input().split()))
D = Counter(A)
res = 0
for i,v in list(D.items()):
    if i > v:
        res += v
    elif i < v:
        res += v-i
print(res)
# Original solution
n=int(eval(input()))
a = list(map(int,input().split()))
a.sort()

c = 0
d = 0 #i

while d <= n-1:
    s = a.count(a[d])
    if a[d] > s:
        c += s
    else:
        c += s-a[d]
    d = d + s
    
print(c)

# Optimized solution
import bisect
n=int(eval(input()))
a = list(map(int,input().split()))
a.sort()
 
c = 0
d = 0 #i
 
while d <= n-1:
    s2 = bisect.bisect_right(a,a[d])
    s = s2-d
    if a[d] > s:
        c += s
    else:
        c += s-a[d]
    d = d + s
    
print(c)
# Original solution
import collections
N=int(eval(input()))
a=list(map(int,input().split()))
a_counter=collections.Counter(a)
answer = 0
# print(a_counter)
# print(a_counter[0])
# print(a_counter[1])
# print(a_counter[2])
# print(a_counter[3])
for i in a_counter:
    # print(i)
    # print(i == a_counter[i])
    if i != a_counter[i]:
        if i < a_counter[i]:
            answer += a_counter[i] - i
        else:
            answer += a_counter[i]

print(answer)

# Optimized solution
import collections
N = int(eval(input()))
a = list(map(int, input().split()))
a_count = collections.Counter(a)
# print(a_count)
ans = 0
for i, j in list(a_count.items()):
    # print(i, j)
    if i <= j:
        ans += j - i
    else:
        ans += j

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

list_a = list(set(a))

result = 0
for i in list_a:
    cnt = a.count(i)
    if cnt != i:
        result = result + cnt if cnt < i else result + cnt - i

print(result)


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

count_a = {}
for n in range(N):
    if a[n] in list(count_a.keys()):
        count_a[a[n]] += 1
    else:
        count_a[a[n]] = 1

result = 0
for n in list(count_a.keys()):
    if count_a[n] != n:
        result = result + count_a[n] if count_a[n] < n else result + count_a[n] - n

print(result)
# Original solution
N=int(eval(input()))
L=list(map(int,input().split()))
S=set(L)
ans=0

for s in S:
    tmp=L.count(s)
    if tmp>s:
        ans+=tmp-s
    elif tmp<s:
        ans+=tmp

print(ans)


# Optimized solution
N=int(eval(input()))
L=list(map(int,input().split()))
S=set(L)
ans=0
dict={}

for s in S:
    dict[s]=0

for l in L:
    dict[l]+=1

for d in list(dict.items()):
    num=d[0]
    amount=d[1]

    if amount>num:
        ans+=amount-num
    elif amount<num:
        ans+=amount

print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(set(a))
ans = 0
for i in b:
    c = a.count(i)
    if c < i:
        ans += c
    if c > i:
        ans += c - i
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1
ans = 0
for i in d:
    if d[i] < i:
        ans += d[i]
    if d[i] > i:
        ans += d[i] - i
print(ans)
# Original solution
n = int(eval(input()))
aList = list(map(int, input().split()))
aSet = list(set(aList))
aSum = 0
for a in aSet:
    aCount = aList.count(a)
    if aCount > a:
        aSum += aCount - a
        continue
    if aCount == a:
        continue
    if aCount < a:
        aSum += aCount
        continue
print(aSum)


# Optimized solution
n = int(eval(input()))
aList = list(map(int, input().split()))
aLen = len(aList)
aSet = sorted(list(set(aList)))
aSum = 0
for a in aSet:
    aCount = aList.count(a)
    if aCount > a:
        aSum += aCount - a
    if aCount < a:
        aSum += aCount
    aLen -= aCount
    if a > aLen:
        aSum += aLen
        break

print(aSum)
# Original solution
import collections

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

c = collections.Counter(List) #要素と出現回数の辞書
value, count = list(zip(*c.most_common()))


newList=[]

for i in range(len(value)):
    if N-len(newList)>=value[i] and count[i]>=value[i]:
        for j in range(value[i]):
            newList.append(value[i])
    else:
        continue

#print(newList)

Ans=len(List)-len(newList)
print(Ans)

# Optimized solution
import collections

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

c = collections.Counter(A) #要素と出現回数の辞書
#print(c)

ans = 0
for k,v in list(c.items()):
    ans += v if v<k else v-k
print(ans)
# Original solution
N=int(eval(input()))
a=list(map(int,input().split()))
ans=0
aa=list(set(a))

for i in aa:
    cnt=a.count(i)
    if cnt>i:
        ans+=cnt-i
    elif cnt<i:
        ans+=cnt

print((str(ans)))




# Optimized solution
N=int(eval(input()))
a=list(map(int,input().split()))
ans=0
aa=list(set(a))
dict={}
for s in aa:
    dict[s]=0
for l in a:
    dict[l]+=1
for i in list(dict.items()):
    num=i[0]
    amount=i[1]
    """                                                           
    cnt=a.count(i)                                                
    if cnt>i:                                                     
        ans+=cnt-i                                                
    elif cnt<i:                                                   
        ans+=cnt                                                  
    """
    if amount>num:
        ans+=amount-num
    elif amount<num:
        ans+=amount
print((str(ans)))
# Original solution
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
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)]
mod = 1000000007
 
#A
"""
a, b = LI()
print((a+b+1)//2)
"""
 
#B
"""
a = S()
a = a[:-1]
b = S()
b = b[:-1]
a.sort()
b.sort(reverse=True)
if a < b:
    print("Yes")
else:
    print("No")
"""
 
#C
n = I()
a = LI()
seta = set(a)
ans = 0
for i in seta:
    x = a.count(i)
    if x != 0 and x >= i:
        ans += x - i
    else:
        ans += x
print(ans)

# Optimized solution
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
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)]
mod = 1000000007

#A
"""
a, b = LI()
print((a+b+1)//2)
"""

#B
"""
a = S()
a = a[:-1]
b = S()
b = b[:-1]
a.sort()
b.sort(reverse=True)
if a < b:
    print("Yes")
else:
    print("No")
"""

#C
n = I()
a = LI()
a.sort()
seta = set(a)
ans = 0
for i in seta:
    x = bisect.bisect_right(a,i) - bisect.bisect_left(a,i)
    if x != 0 and x >= i:
        ans += x - i
    else:
        ans += x
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))
dic = {}
count = 0

for i in range(n):
  dic.setdefault(l[i],0)
  dic[l[i]] += 1

for x,y in list(dic.items()):
  if x <= y:
    count += y - x
  else:
    count += y
print(count)


# Optimized solution
n = int(eval(input()))
l = list(map(int,input().split()))
d = {}
ans = 0
for i in l:
  if i not in d:
    d[i] = 1
  else:
    d[i] += 1
for k,v in list(d.items()):
  if k != v:
    if k < v:
      ans += v - k
    else:
      ans += v
print(ans)
# Original solution
from itertools import groupby
n, s = eval(input()), sorted(map(int, input().split()))
v, ans = [(i, len(list(t))) for i, t in groupby(s)], 0
for i, t in v:
    if i == t:
        continue
    ans += ((t - i) if i < t else t)
print(ans)


# Optimized solution
from itertools import groupby
n, s = eval(input()), sorted(map(int, input().split()))
v, ans = [(i, len(list(t))) for i, t in groupby(s)], 0
for i, t in v:
    if i != t:
        ans += ((t - i) if i < t else t)
print(ans)
# Original solution
n = int(eval(input()))
a = [int(_) for _ in input().split()]

res = 0

for i in set(a):
    tmp = a.count(i)
    if tmp < i:
        res += tmp
    else:
        res += tmp - i

print(res)

# Optimized solution
import bisect
n = int(eval(input()))
a = [int(_) for _ in input().split()]
a.sort()

res = 0

for i in set(a):
    tmp = bisect.bisect_right(a,i)-bisect.bisect_left(a,i)
    if tmp < i:
        res += tmp
    else:
        res += tmp - i

print(res)
# Original solution
from collections import Counter
N=int(eval(input()))
A=list(map(int,input().split()))
d=Counter(A)
ans=0
for i in d:
  if d[i]>=i:
    ans+=d[i]-i
  else:
    ans+=d[i]
print(ans)

# Optimized solution
from collections import Counter
n=int(eval(input()))
a=Counter(input().split())
ans=0
for i,j in list(a.items()):
    i=int(i)
    if i>j:
        ans+=j
    elif i<j:
        ans+=j-i
print(ans)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
ctr=0
el=[]
for i in range(n):
    if a[i] not in el:
        num=a.count(a[i])
        el.append(a[i])
        if a[i]>num:
            ctr+=num
        else:
            ctr+=num-a[i]
print(ctr)


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort()
ctr=1
ln=[]
for i in range(n-1):
    if a[i]==a[i+1]:
        ctr+=1
    elif a[i]!=a[i+1]:
        ln.append([a[i],ctr])
        ctr=1
ln.append([a[n-1],ctr])
ans=0
for k in range(len(ln)):
    if ln[k][0]>ln[k][1]:
        ans+=ln[k][1]
    else:
        ans+=ln[k][1]-ln[k][0]
print(ans)
# Original solution
import collections

ans = 0
N = int(eval(input()))
a = [int(i) for i in input().split()]

dic = collections.Counter(a).most_common()
for a, b in dic:
    if a <= b:
        ans += b-a
    else:
        ans += b
print(ans)

# Optimized solution
import collections

N = int(eval(input()))
a = [int(i) for i in input().split()]
ans = 0

num = collections.Counter(a).most_common()

for a, b in num:
    if b < a:
        ans += b
    elif a < b:
        ans += b-a
print(ans)
# Original solution
from collections import Counter
N = int(eval(input()))
A = Counter(list(map(int, input().split())))
ans = 0
for x, y in list(A.items()):
  if y >= x:
    ans += y - x
  else:
    ans += y
print(ans)

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

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

d = {}
for ai in a:
  if not ai in d:
    d[ai] = a.count(ai)

cnt = 0
for key, value in list(d.items()):
  if key > value:
    cnt = cnt + value
  elif key < value:
    cnt = cnt + value - key

print(cnt)

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

d = {}
for ai in a:
  if ai in d:
    d[ai] = d[ai] + 1
  else:
    d[ai] = 1

cnt = 0
for key, value in list(d.items()):
  if key > value:
    cnt = cnt + value
  elif key < value:
    cnt = cnt + value - key

print(cnt)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
for i in set(a):
    if i <= a.count(i):
        n -= i
print(n)

# 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
for k,v in list(d.items()):
    if k <= v:
        n -= k
print(n)
# Original solution
N=int(eval(input()))
a=list(map(int,input().split()))

s=set(a)
count=0

for i in s:
    if a.count(i)-i<0:
        count+=a.count(i)
    else:
        count+=a.count(i)-i
print(count)

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

a=sorted(a)
s=set(a)
count=0

base=0
judge=0

for i in a:
    if base!=i:
        #print(judge,base)
        if judge>=base:
            count+=judge-base
        else:
            count+=judge
        base=i
        judge=1
    else:
        judge+=1
if judge>=base:
    count+=judge-base
else:
    count+=judge


print(count)
# Original solution
import collections
N = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
array = list(set(a))
sum = 0
for i in range(len(array)):
    if a.count(array[i]) >= array[i]:
        sum += a.count(array[i]) - array[i]
    else:
        sum += a.count(array[i])
print(sum)

# Optimized solution
N = int(eval(input()))
a = list(map(int,input().split()))
A = a.sort()
array = list(set(a))
array.sort()
sum = 0
n = 0
for i in range(len(array)):
    cnt = 0
    for j in range(n,len(a)):
        if array[i] == a[j]:
            cnt += 1
        else:
            break
    n += cnt
    if cnt >= array[i]:
        sum += cnt - array[i]
    else:
        sum += cnt
print(sum)
# Original solution
N = int(eval(input()))
a = sorted([int(x) for x in input().split()])
i,ans = 0,0
while i < N:
    c = a.count(a[i])
    if c > a[i]:
        ans += c-a[i]
    elif c < a[i]:
        ans += c
    i += c

print(ans)



# Optimized solution
N = int(eval(input()))
a = sorted([int(x) for x in input().split()])
i,ans = 0,0
while i < N:
    if a[i] > N:
        ans += N-i
        break
    c = a.count(a[i])
    if c > a[i]:
        ans += c-a[i]
    elif c < a[i]:
        ans += c
    i += c

print(ans)
# Original solution
N=int(eval(input()))
st=input().split()
a=[0 for i in range(N)]
M=set([])
for i in range(N):
    a[i]=int(st[i])
    M.add(a[i])
Numlist=list(M)
b=[0 for i in range(len(M))]
def search(num):
    for k in range(len(M)):
        if Numlist[k]==num:
            return k
    return -1
for i in range(N):
    b[search(a[i])]+=1
count=0
for i in range(len(M)):
    if Numlist[i]<=b[i]:
        count+=b[i]-Numlist[i]
    else:
        count+=b[i]
print(count)

# Optimized solution
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)
# Original solution
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)



# Optimized solution
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)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))

a.sort()
amax=a[-1]
amin=a[0]

dn=0
for i in range(amin,amax+1):
    ni=a.count(i)
    if ni>i:
        dn=dn+(ni-i)
    elif ni<i:
        dn=dn+ni

print(dn)        


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

a.sort()
amax=a[-1]
amin=a[0]

s=[]
ai=a[0]
acnt=-1
for i in range(n):
    if a[i]>ai:
        s.append([ai,acnt+1])
        acnt=0
        ai=a[i]
    else:
        acnt=acnt+1
s.append([ai,acnt+1])
        
# print(s)
    
dn=0
for i in range(len(s)):
    ni=s[i][1]
    if ni>s[i][0]:
        dn=dn+(ni-s[i][0])
    elif ni<s[i][0]:
        dn=dn+ni

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

a.sort()
amax=a[-1]
amin=a[0]

s=[]
ai=a[0]
acnt=-1
for i in range(n):
    if a[i]>ai:
        s.append([ai,acnt+1])
        acnt=0
        ai=a[i]
    else:
        acnt=acnt+1
s.append([ai,acnt+1])
        
# print(s)
    
dn=0
for i in range(len(s)):
    ni=s[i][1]
    if ni>s[i][0]:
        dn=dn+(ni-s[i][0])
    elif ni<s[i][0]:
        dn=dn+ni

print(dn)        

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

d=dict()

for i in range(n):
    if a[i] in d:
        d[a[i]]=d[a[i]]+1
    else:
        d[a[i]]=1
        
xsum=0
for x in list(d.keys()):
    if d[x]<x:
        xsum=xsum+d[x]
    elif d[x]>x:
        xsum=xsum+d[x]-x
        
print(xsum)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=set()
ans=0
for i in a:
    if i not in b:
        b.add(i)
        x=a.count(i)
        if x>=i:
            ans+=x-i
        else:
            ans+=x
print(ans)

# Optimized solution
n=int(eval(input()))
a=sorted(list(map(int,input().split())))
b=set()
ans=0
d={}
cnt=0
for i in range(n):
    if i!=0 and a[i]!=a[i-1]:
        d[a[i-1]]=cnt
        cnt=0
    cnt+=1
    if i==n-1:
        x=a.count(a[i])
        d[a[i]]=x
for i in list(d.keys()):
    if d[i]>=i:
        ans+=d[i]-i
    else:
        ans+=d[i]
print(ans)