import java.util.*;
import java.util.function.Predicate;

public class Problem {

	public static void main(String[] args) {
			
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int [] mask = new int[n];
		int [] p = new int[n/2];
		for (int i=0;i<n/2;i++){
			p[i]=Integer.parseInt(sc.next())-1;
		}
		for (int i=0;i<n;i++){
			if (i%2==1) mask[i]=1;			
		}
		for (int j=0;j<n/2;j++){			
			mask[p[j]]++;			
		}
	
		List<Integer> m = new ArrayList<>();
		List<Integer> M = new ArrayList<>();
		for (int i=0;i<n;i++){
			if (mask[i]==0){
				m.add(i);
			}
			if (mask[i]==2){
				M.add(i);
			}
		}
		
		
		int result = 0;
		for (int i=0;i<M.size();i++){
			result+=Math.abs(M.get(i)-m.get(i));
		}
		
		System.out.println(result);
		
	}

}