from sys import stdin

rints = lambda: [int(x) for x in stdin.readline().split()]
n, a, ans = int(input()), rints(), [0, 0]
for i in range(n):
    ans[i % 2] += abs(a[i // 2] - (i + 1))
print(min(ans))