import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class CF21 {

	final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	final static PrintWriter pw = new PrintWriter(System.out);

	public static void main(String[] args) {

		int n = readInt();

		int[] arr = readIntArr();

		int mn = Math.min(numMove(arr, 0), numMove(arr,1));
		pw.println(mn);
		pw.close();

	}

	static int numMove(int[] arr, int w) {
		Set<Integer> hv = new HashSet<Integer>();
		for (int i : arr)
			hv.add(i);
		int n=arr.length*2;
		int count=0;
		for(int i=1;i<=n;i++) {
			
			if(i%2==w) {
				if(!hv.contains(i)) {
					for(int j=i+1;j<=n;j++) {
						if(hv.contains(j)) {
							hv.remove(j);
							count+=j-i;
							break;
						}
					}
				}
			}else {
				if(hv.contains(i)) {
					for(int j=i+1;j<=n;j++) {
						if(!hv.contains(j)) {
							count+=j-i;
							hv.add(j);
							break;
						}
					}
				}
			}
		}
		return count;
	}

	static String readLine() {
		String line = null;
		try {
			line = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return line;

	}

	static String readString() {
		return readLine();

	}

	static public long readlong() {
		return Long.parseLong(readLine());
	}

	static public int readInt() {
		return Integer.parseInt(readLine());
	}

	static String[] stringArray() {

		StringTokenizer st = new StringTokenizer(readLine());
		int n = st.countTokens();
		String ret[] = new String[n];
		for (int i = 0; i < n; i++) {
			ret[i] = st.nextToken();
		}
		return ret;

	}

	static public int[] readIntArr() {
		String[] str = stringArray();
		int arr[] = new int[str.length];
		for (int i = 0; i < arr.length; i++)
			arr[i] = Integer.parseInt(str[i]);
		return arr;
	}

	static public double[] readDoubleArr() {
		String[] str = stringArray();
		double arr[] = new double[str.length];
		for (int i = 0; i < arr.length; i++)
			arr[i] = Double.parseDouble(str[i]);
		return arr;
	}

	static public long[] readLongArr() {
		String[] str = stringArray();
		long arr[] = new long[str.length];
		for (int i = 0; i < arr.length; i++)
			arr[i] = Long.parseLong(str[i]);
		return arr;
	}

	static public double readDouble() {
		return Double.parseDouble(readLine());
	}
}