N = int(input()) A = list(map(int,input().split())) ans = 0 for i in range(N): for j in range(i+1,N): if min(A[i],A[j]) >= 2: ans += 1 elif max(A[i],A[j])-min(A[i],A[j]) > 1: ans += min(A[i],A[j])+1 else: ans += max(A[i],A[j])+1 print(ans)