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 = []

if min(fi) in ar:
	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

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

	ans = 0

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

	print ans