n = int(input()) a = [i for i in map(int, input().split())] ans = 0 def mex(a,b): if a != 1 and b != 1: return 1 if a == 1 and b == 1: return 2 if a == 1 or b == 1 and abs(a-b) == 1: return 3 if a == 1 or b == 1 and abs(a-b) >= 2: return 2 for i in range(1,n): for j in range(i+1,n+1): ans += mex(a[i-1],a[j-1]) print(ans)