def solve(seq, num):
    last_free_cell = 1
    ans = 0
    for el in seq:
        ans += abs(el - last_free_cell)
        last_free_cell+=2

    return ans


n= int(input())

data = list(map(int,input().split()))

print(min(solve(data , n), solve(data[::-1], n)))
