You are given a chessboard of size 1 × n. It is guaranteed that n is even. The chessboard is painted like this: "BWBW...BW".

Some cells of the board are occupied by the chess pieces. Each cell contains no more than one chess piece. It is known that the total number of pieces equals to $\frac{n}{2}$.

In one step you can move one of the pieces one cell to the left or to the right. You cannot move pieces beyond the borders of the board. You also cannot move pieces to the cells that are already occupied.

Your task is to place all the pieces in the cells of the same color using the minimum number of moves (all the pieces must occupy only the black cells or only the white cells after all the moves are made).


-----Input-----

The first line of the input contains one integer n (2 ≤ n ≤ 100, n is even) — the size of the chessboard. 

The second line of the input contains $\frac{n}{2}$ integer numbers $p_{1}, p_{2}, \ldots, p_{\frac{n}{2}}$ (1 ≤ p_{i} ≤ n) — initial positions of the pieces. It is guaranteed that all the positions are distinct.


-----Output-----

Print one integer — the minimum number of moves you have to make to place all the pieces in the cells of the same color.


-----Examples-----
Input
6
1 2 6

Output
2

Input
10
1 2 3 4 5

Output
10



-----Note-----

In the first example the only possible strategy is to move the piece at the position 6 to the position 5 and move the piece at the position 2 to the position 3. Notice that if you decide to place the pieces in the white cells the minimum number of moves will be 3.

In the second example the possible strategy is to move $5 \rightarrow 9$ in 4 moves, then $4 \rightarrow 7$ in 3 moves, $3 \rightarrow 5$ in 2 moves and $2 \rightarrow 3$ in 1 move.

Difficulty: interview

Starter code:

Solutions:
def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

n = ii()
a = li()
a.sort()
c1 = 0
p = 1
for ai in a:
    c1 += abs(ai - p)
    p += 2
c2 = 0
p = 2
for ai in a:
    c2 += abs(ai - p)
    p += 2
ans = min(c1, c2)
print(ans)

n = int(input())
p = list(map(int, input().split()))
p.sort()
x = 0
y = 0
for i in range(n // 2):
    p[i] -= 1
    x += abs(p[i] - 2 * i)
    y += abs(p[i] - 2 * i - 1)
print(min(x, y))


import sys
def mp():
    return list(map(int,sys.stdin.readline().split()))
n = int(input())
a = sorted(list(mp()))
w = 0
i = 1
b = 0
j = 2
for x in range(n//2):
    w += abs(a[x] - i)
    b += abs(a[x] - j)
    i+=2
    j+=2
print(min(w,b))



n = int(input())
a = [int(i) for i in input().split()]
for i in range(n // 2):
    a[i] -= 1
ans1 = 0
ans2 = 0
a.sort()
for i in range(n // 2):
    ans1 += abs(a[i] - 2 * i)
    ans2 += abs(a[i] - 2 * i - 1)
print(min(ans1, ans2))


n = int(input())
a = sorted(map(int, input().split()))
r1 = sum(abs(a[i] - 2 * i - 1) for i in range(n // 2))
r2 = sum(abs(a[i] - 2 * i - 2) for i in range(n // 2))
print(min(r1, r2))


n = int(input())
a = sorted(list(map(int, input().split())))

ansA, ansB = 0, 0

for i in range(n // 2):
    u, v = i * 2 + 1, i * 2 + 2
    ansA += abs(a[i] - u)
    ansB += abs(a[i] - v)

print(min(ansA, ansB))


def main():
    n = int(input())
    ans1 = 0
    ans2 = 0
    a = list(map(int, input().split()))
    a.sort()
    b1 = []
    b2 = []
    for i in range(1, n + 1):
        if (i % 2 == 0):
            b1.append(i)
        else:
            b2.append(i)
    for i in range(n // 2):
        ans1 += abs(a[i] - b1[i])
    for i in range(n // 2):
        ans2 += abs(a[i] - b2[i])    
    print(min(ans1, ans2))
main()

n=int(input())
arr=list(map(int,input().split()))
arr.sort()
sum1=0
j=1
k=2
sum2=0
for i in range(len(arr)):
	sum1+=abs(j-arr[i])
	sum2+=abs(k-arr[i])
	j+=2
	k+=2
print(min(sum1,sum2))


#!/usr/bin/env python3

n = int(input().strip())
pis = list(map(int, input().strip().split()))

pis.sort()

w1 = sum(abs(2 * i + 1 - p) for i, p in enumerate(pis))
w2 = sum(abs(2 * i + 2 - p) for i, p in enumerate(pis))

print(min(w1, w2))


import math
n = int(input())
cnt0 = 0
cnt1 = 0
p = input().split()
for i in range(n//2):
    p[i] = int(p[i])-1
p.sort()
for i in range(n//2):
    cnt0+=math.fabs(p[i]-2*i)
    cnt1+=math.fabs(p[i] - 2*i-1)
print(int(min(cnt0,cnt1)))    

            
        
    
    
    
    
        
    
    
    

    
    
   



n=int(input())
arr=list(map(int,input().strip().split(' ')))
arr.sort()
ind = n
cnt = 0
for i in range(n//2-1,-1,-1):
  cnt = cnt + abs(arr[i]-ind)
  ind-=2
cnt1=0
ind=n-1
for i in range(n//2-1,-1,-1):
  cnt1 = cnt1 + abs(arr[i]-ind)
  ind-=2
print(min(cnt,cnt1))


n = int(input())
n >>= 1
sum1, sum2 = 0, 0
a = list(map(int, input().split()))
a.sort()
for i in range(n):
    sum1 += abs(a[i]-(i*2+1))
    sum2 += abs(a[i]-(i+1)*2)
print(min(sum1, sum2))


n = int(input())
p = list(sorted(map(int, input().split())))
s1 = s2 = 0
for i in range(n // 2):
    k = 1 + i * 2
    s1 += abs(p[i] - k)
    s2 += abs(p[i] - k - 1)
print(min(s1, s2))


def feven(pieces, n):
    res = 0
    for i in range(len(pieces)):
        res += abs(pieces[i] - 2 * (1 + i))
    return res
def fodd(pieces, n):
    res = 0
    for i in range(len(pieces)):
        res += abs(pieces[i] - (2 * (1 + i) - 1))
    return res


n = int(input())

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

pieces = sorted(pieces)

ans1 = feven(pieces, n)

ans2 = fodd(pieces, n)

print(min(ans1, ans2))

n = int (input())
a = list(map(int,input().split()))
a.sort()
b = [0] * (n // 2)
b[0] = 2
for i in range(1, n // 2):
    b[i] = b[i - 1] + 2
cnt  = 0;
for i in range(n // 2):
    cnt += abs(a[i] - b[i])
c = 0
for i in range(n // 2):
    c += abs(a[i] - (b[i] - 1))
print(min(c,cnt))

n = int(input())
arr = list(map(int, input().split()))
arr.sort()
n = n // 2
s_1 = 0
s_2 = 0
nech = 1
chet = 2
for i in range(n):
    s_1 = s_1 + abs(nech - arr[i])
    nech += 2
    s_2 = s_2 + abs(chet - arr[i])
    chet +=2
print(min(s_1,s_2))

n = input()
a = list(map(int, input().split()))

def main():
    a.sort()

    b = w = 0

    for i, x in enumerate(a):
        x -= 1

        b += abs(2 * i - x)
        w += abs(2 * i + 1 - x)

    print(min(b, w))

main()


n=int(input())
a=[int(x) for x in input().split()]
a=sorted(a)
l=len(a)
a1=[]
a2=[]
for i in range(1,n,2):
    a1.append(i)
for i in range(2,n+1,2):
    a2.append(i)
s1=0
s2=0
for i in range(l):
    s1=s1+abs(a1[i]-a[i])
for i in range(l):
    s2=s2+abs(a2[i]-a[i])
print(min(s1,s2))


n = int(input())
p = [int(v) for v in input().split()]
p.sort()

a = sum(abs(pp - ii) for (ii, pp) in zip(list(range(1, n + 1, 2)), p))
b = sum(abs(pp - ii) for (ii, pp) in zip(list(range(2, n + 1, 2)), p))

print(min(a, b))


n = int(input())
s = [int(x) for x in input().split()]
s.sort()

sum_even = 0
sum_odd = 0
# Even
for i, k in enumerate(s):
	sum_even += abs(k - (i * 2 + 2))
for i, k in enumerate(s):
	sum_odd += abs(k - (i * 2 + 1))
print(min(sum_even, sum_odd))


n = int(input())
p = sorted([int(x) for x in input().split()])

# B
moves_B = sum([abs(2 * i + 1 - p[i]) for i in range(n // 2)])
moves_W = sum([abs(2 * i + 2 - p[i]) for i in range(n // 2)])

# print(moves_B, moves_W)
print(min(moves_B, moves_W))


n = int(input())
P = input().split(' ')
for i in range(n//2):
    P[i] = int(P[i])
P.sort()
B = [0] * (n//2)
W = [0] * (n//2)
for i in range(n//2):
    B[i] = 2*i+1
    W[i] = 2*i+2
b = 0
w = 0
for i in range(n//2):
    b+=abs(B[i]-P[i])
    w+=abs(W[i]-P[i])
print(min(b, w))


from sys import stdin, stdout
from math import factorial
from math import log10
from math import sqrt

n = int(stdin.readline())
values = sorted(list(map(int, stdin.readline().split())))


cur = 1
cnt = 0
for v in values:
    cnt += abs(v - cur)
    cur += 2

ans = cnt

cur = 2
cnt = 0

for v in values:
    cnt += abs(v - cur)
    cur += 2

ans = min(ans, cnt)

stdout.write(str(ans))

n = int(input())
L = sorted(list(map(int, input().split())))
ans = [0, 0]
for i in range(n//2):
    ans[0] += abs(L[i] - (2*i+1))
    ans[1] += abs(L[i] - (2*i+2))
print(min(ans))

def getIntList():
    return list(map(int, input().split()));
def getTransIntList(n):
    first=getIntList();
    m=len(first);
    result=[[0]*n for _ in range(m)];
    for i in range(m):
        result[i][0]=first[i];
    for j in range(1, n):
        curr=getIntList();
        for i in range(m):
            result[i][j]=curr[i];
    return result;
n=int(input());
p=getIntList();
p.sort();
result1=0;
for i, x in enumerate(p):
    result1+=abs(x-(2*i+1));
result2=0;
for i, x in enumerate(p):
    result2+=abs(x-(2*i+2));
print(min(result1, result2));