Buggy python submission (verdict: Time Limit Exceeded):
ignore = int(raw_input())
k = map(int, raw_input().split())
copyk = list(set(k))
counter = 0

for i in xrange(len(copyk)):
    if (k.count(copyk[i]) > copyk[i]):
        counter+=k.count(copyk[i]) - copyk[i]
    if k.count(copyk[i]) < copyk[i]:
        counter+=k.count(copyk[i])

print counter


Fixed submission:
from collections import Counter

ignore = int(raw_input())
k = dict(Counter(map(int, raw_input().split())))
copyk = list(set(k))
counter = 0
for i,j in k.items():
    if i > j:
        counter += j
    elif i < j:
        counter += j - i

print counter

Buggy python submission (verdict: Time Limit Exceeded):
ignore = int(raw_input())
k = map(int, raw_input().split())
copyk = list(set(k))
counter = 0

for i in xrange(len(copyk)):
    if (k.count(copyk[i]) > copyk[i]):
        counter+=k.count(copyk[i]) - copyk[i]
    if k.count(copyk[i]) < copyk[i]:
        counter+=k.count(copyk[i])

print counter


Fixed submission:
from collections import Counter

ignore = int(raw_input())
k = dict(Counter(map(int, raw_input().split())))
copyk = list(set(k))
counter = 0
for i,j in k.items():
    if i > j:
        counter += j
    elif i < j:
        counter += j - i

print counter

Buggy python submission (verdict: Time Limit Exceeded):
ignore = int(raw_input())
k = map(int, raw_input().split())
copyk = list(set(k))
counter = 0

for i in xrange(len(copyk)):
    if (k.count(copyk[i]) > copyk[i]):
        counter+=k.count(copyk[i]) - copyk[i]
    if k.count(copyk[i]) < copyk[i]:
        counter+=k.count(copyk[i])

print counter


Fixed submission:
from collections import Counter

ignore = int(raw_input())
k = dict(Counter(map(int, raw_input().split())))
copyk = list(set(k))
counter = 0
for i,j in k.items():
    if i > j:
        counter += j
    elif i < j:
        counter += j - i

print counter

Buggy python submission (verdict: Time Limit Exceeded):
ignore = int(raw_input())
k = map(int, raw_input().split())
copyk = list(set(k))
counter = 0


for i in xrange(len(copyk)):
    while(k.count(copyk[i]) > copyk[i]):
        k.remove(copyk[i])
        counter += 1
    if k.count(copyk[i]) < copyk[i]:
        while(copyk[i] in k):
            k.remove(copyk[i])
            counter += 1


print counter


Fixed submission:
from collections import Counter

ignore = int(raw_input())
k = dict(Counter(map(int, raw_input().split())))
copyk = list(set(k))
counter = 0
for i,j in k.items():
    if i > j:
        counter += j
    elif i < j:
        counter += j - i

print counter

Buggy python submission (verdict: Time Limit Exceeded):
ignore = int(raw_input())
k = map(int, raw_input().split())
copyk = list(set(k))
counter = 0


for i in xrange(len(copyk)):
    while(k.count(copyk[i]) > copyk[i]):
        k.remove(copyk[i])
        counter += 1
    if k.count(copyk[i]) < copyk[i]:
        while(copyk[i] in k):
            k.remove(copyk[i])
            counter += 1


print counter


Fixed submission:
from collections import Counter

ignore = int(raw_input())
k = dict(Counter(map(int, raw_input().split())))
copyk = list(set(k))
counter = 0
for i,j in k.items():
    if i > j:
        counter += j
    elif i < j:
        counter += j - i

print counter

Buggy python submission (verdict: Time Limit Exceeded):
ignore = int(raw_input())
k = map(int, raw_input().split())
copyk = list(set(k))
counter = 0


for i in range(len(copyk)):
    while(k.count(copyk[i]) > copyk[i]):
        k.remove(copyk[i])
        counter += 1
    if k.count(copyk[i]) < copyk[i]:
        while(copyk[i] in k):
            k.remove(copyk[i])
            counter += 1


print counter


Fixed submission:
from collections import Counter

ignore = int(raw_input())
k = dict(Counter(map(int, raw_input().split())))
copyk = list(set(k))
counter = 0
for i,j in k.items():
    if i > j:
        counter += j
    elif i < j:
        counter += j - i

print counter