N = int(input()) B = [int(b) - 1 for b in input().split()] hoge = ans = 0 for b in B: hoge += b ans += abs(hoge) print(ans)