n = int(input()) a = list(map(int,input().split())) a.sort() dic = {} for i in a: dic[i] = 1 ans = n for i in range(1,n): if a[i] == a[i-1]+1: count = 0 k = a[i] while k+count*2 in dic: count += 1 ans += count print(ans)