N = int(input()) B = list(map(int,input().split())) tmp = 0 ans = 0 for i in B: tmp += i - 1 ans += abs(tmp) print(ans)