n = int(raw_input())
ar = map(int, raw_input().split())

ar1 = [i for i in xrange(1,n+1) if i not in ar]

fi = [x for x in xrange(1,n+1)]

k = 0

fin = []

for j in xrange((n/2)):
	fin.append(ar[j])
	fin.append(ar1[j])

ans = 0

for f in ar:
	ans += (abs(fin.index(f) - fi.index(f)))

print ans