import sys from collections import defaultdict def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N = I() A = LI() A.sort() d = defaultdict(int) # d[a] == 1 ⇔ a in A for a in A: d[a] = 1 count = defaultdict(int) # count[a] = A内の要素で構成された初項a、公差2の等差数列の最大の長さ for a in A: count[a] = 0 for a in A: if count[a] == 0: b = a while d[b] == 1: b += 2 r = (b-a)//2 for i in range(a,b,2): count[i] = r-(i-a)//2 ans = N for a in A: ans += count[a+1] print(ans)