N = int(input()) A = list(map(int, input().split())) diff = 0 ans = 0 for a in A: ans += abs(diff) diff += a - 1 print(ans)