Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in b:
    nc=0
    for j in range(len(a)):
        if a[j]==i:
          nc+=1
        else:
          nc+=0    
    c+= nc-i if nc-i>=0 else nc
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in b:
    k = a.count(i)
    c+= k-i if k-i>=0 else k
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in b:
    c+= a.count(i) - i if a.count(i) - i>=0 else a.count(i) 
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in b:
    nc=0
    for j in range(len(a)):
        if a[j]==i:
          nc+=1
        else:
          nc+=0    
    er = nc - i
    if er<0:
        c+= er+i
    else:
        c+=er
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in b:
    er = a.count(i) - i
    if er<0:
        c+= er+i
    else:
        c+=er
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in range(len(b)):
    er = a.count( b[i] ) - b[i]
    if er<0:
        c+= er + b[i]
    else:
        c+=er
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in range(len(b)):
    er = a.count( b[i] ) - b[i]
    if er<0:
        c+= a.count( b[i] )
    else:
        c+=er
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in range(len(b)):
    er = a.count( b[i] ) - b[i]
    if er<0:
        er = a.count( b[i] )
    c+=er
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

b=list(set(a))
c=0
for i in range(len(b)):
    er = a.count( b[i] ) - b[i]
    if er<0:
        er = a.count( b[i] )
    c+=er
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
a.sort()
b=list(set(a))
c=0
for i in range(len(b)):
    er = a.count( b[i] ) - b[i]
    if er<0:
        er = a.count( b[i] )
    if er>0:
        c+=er
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
 
a.sort()
b=list(set(a))
c=0
for i in range(len(b)):  
  if a.count( b[i] ) != b[i]:
    er = a.count( b[i] ) - b[i]
    if er<0:
      er = a.count( b[i] )
    if er>0:
      c+=er
print(c)

Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

a.sort()
b=list(set(a))
c=0
for i in range(len(b)):  
  if a.count( b[i] ) != b[i]:
    er = a.count( b[i] ) - b[i]
    if er<0:
      er = a.count( b[i] )
    if er>0:
      for j in range(er):
        a.remove( b[i] )
        c+=1
print(c)



Fixed submission:
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)