package zlatnici;

import static java.lang.Math.abs;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author Ivan
 */
public class Zlatnici {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N, trenutna1 = 0, trenutna2 = 0;
        int[] r;
        int[] c;
        N = input.nextInt();
        r = new int[N];
        c = new int[N];
        for (int i = 0; i < N; i++) {
            r[i] = input.nextInt();
            c[i] = input.nextInt();
        }

        Arrays.sort(r);
        Arrays.sort(c);
        
        for (int i = 0; i < N; i++) {
            trenutna1 = trenutna1 + abs(r[i] - (i + 1));
        }
        
        for (int i = 0; i < N; i++) {
            trenutna2 = trenutna2 + abs(c[i] - (i + 1));
        }
        
        System.out.println(trenutna1 + trenutna2);
    }
}