import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,*A = map(int,read().split()) X = [] for i,x in enumerate(A): X += [i] * x answer = sum(abs(x-i) for i,x in enumerate(X)) print(answer)