from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a.sort()
dic = Counter(a)
k = -1
kv = -1
cnt = 0
for key,value in dic.items():
    if key == k + 1 :
        if value > kv :
            cnt += value-kv
        kv = value
        k = key
    else :
        cnt += value
        kv = value
        k = key
print(cnt)

最核心的就一点,对于排序后的数字,下一个被计数的数的数量最终纳入结果的数量只和上一个数的数量有关