def get_minimum(list1):
    min1=min(list1)
    if min1==1 or min1==2:
        return min1
    counteven=0
    countodd=0
    for i in list1:
        if i%2==0:
            counteven=counteven+1
        else:
            countodd=countodd+1
    if countodd>counteven:
        return 1
    else:
        return 2

def process():
    totalsize=int(raw_input())
    list1=[int(i) for i in raw_input().split()]
    if totalsize>2:
        min1=get_minimum(list1)
        list2=[i for i in range(min1,totalsize+1,2)]
        ans=sum([abs(list2[i]-list1[i]) for i in range(len(list1))])
        print(ans)
    else:
        print("0")

process()