n=int(input())
a=[int(i) for i in input().split()]
nch=[]
ch=[]
i,j=1,0
cnt1=0
cnt2=0
while i<n:
    nch.append(i)
    ch.append(i+1)
    i+=2
while j<n//2:
    cnt1+=((nch[j]-a[j])**2)**(1/2)
    cnt2+=((ch[j]-a[j])**2)**(1/2)
    j+=1
if cnt1>cnt2:
    print(int(cnt2))
else:
    print(int(cnt1))