Buggy python submission (verdict: Time Limit Exceeded):
N = input()
list = [int(a) for a in input().split()]
count = 0
stack = []
for i in list:
    if stack.count(i) == 0:
        if i > list.count(i):
            count += list.count(i)
        else:
            count += list.count(i) - i
        stack.append(i)                           
print(count)

Fixed submission:
N = int(input())
list = [int(a) for a in input().split()]
dict = dict()
for i in range(N):
    if list[i] in dict:
        dict[list[i]] += 1
    else:
        dict[list[i]] = 1
count = 0
for i, j in dict.items():
#    print(i, j) 
    if i <= j:
        count += j - i
    else:
        count += j
              
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
list = [int(a) for a in input().split()]
count = 0
stack = []
for i in list:
    if stack.count(i) == 0:
        if i > list.count(i):
            count += list.count(i)
        else:
            count += list.count(i) - i
        stack.append(i)                           
print(count)

Fixed submission:
N = int(input())
list = [int(a) for a in input().split()]
dict = dict()
for i in range(N):
    if list[i] in dict:
        dict[list[i]] += 1
    else:
        dict[list[i]] = 1
count = 0
for i, j in dict.items():
#    print(i, j) 
    if i <= j:
        count += j - i
    else:
        count += j
              
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
list = [int(a) for a in input().split()]
count = 0
stack = []
for i in list:
    if stack.count(i) == 0:
        if i > list.count(i):
            count += list.count(i)
        else:
            count += list.count(i) - i
        stack.append(i)                           
print(count)

Fixed submission:
N = int(input())
list = [int(a) for a in input().split()]
dict = dict()
for i in range(N):
    if list[i] in dict:
        dict[list[i]] += 1
    else:
        dict[list[i]] = 1
count = 0
for i, j in dict.items():
#    print(i, j) 
    if i <= j:
        count += j - i
    else:
        count += j
              
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
list = [int(a) for a in input().split()]
count = 0
for i in range(len(list)):
    if list[i] != list.count(list[i]):
        list.remove(list[i])
        count += 1
    if i == len(list)-1:
        break
print(count)
        

Fixed submission:
N = int(input())
list = [int(a) for a in input().split()]
dict = dict()
for i in range(N):
    if list[i] in dict:
        dict[list[i]] += 1
    else:
        dict[list[i]] = 1
count = 0
for i, j in dict.items():
#    print(i, j) 
    if i <= j:
        count += j - i
    else:
        count += j
              
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
list = [a for a in input().split()]
count = 0
A = len(list)
for i in range(A):
#    print(list[i])
 #   print(list.count(list[i]))
    if list[i] != list.count(list[i]):
        list.remove(list[i])
        count += 1
    if i == len(list)-1:
        break
 #   print(list)
 #   print(count)
print(count)
        

Fixed submission:
N = int(input())
list = [int(a) for a in input().split()]
dict = dict()
for i in range(N):
    if list[i] in dict:
        dict[list[i]] += 1
    else:
        dict[list[i]] = 1
count = 0
for i, j in dict.items():
#    print(i, j) 
    if i <= j:
        count += j - i
    else:
        count += j
              
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
list = [a for a in input().split()]
count = 0
for i in range(len(list)):
#    print(list[i])
 #   print(list.count(list[i]))
    if list[i] != list.count(list[i]):
        list.remove(list[i])
        count += 1
    if i == len(list)-1:
        break
 #   print(list)
 #   print(count)
print(count)
        

Fixed submission:
N = int(input())
list = [int(a) for a in input().split()]
dict = dict()
for i in range(N):
    if list[i] in dict:
        dict[list[i]] += 1
    else:
        dict[list[i]] = 1
count = 0
for i, j in dict.items():
#    print(i, j) 
    if i <= j:
        count += j - i
    else:
        count += j
              
print(count)

Buggy python submission (verdict: Runtime Error):
N = input()
list = [a for a in input().split()]
count = 0
for i in range(len(list)):
    if not list[i] == list.count(i):
        list.remove(list[i])
        count += 1
    if i == len(list)-1:
        break
print(count)
        

Fixed submission:
N = int(input())
list = [int(a) for a in input().split()]
dict = dict()
for i in range(N):
    if list[i] in dict:
        dict[list[i]] += 1
    else:
        dict[list[i]] = 1
count = 0
for i, j in dict.items():
#    print(i, j) 
    if i <= j:
        count += j - i
    else:
        count += j
              
print(count)