public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int minX = Integer.MAX_VALUE;
        int maxX = Integer.MIN_VALUE;


        int[] allY = new int[n];
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            minX = Math.min(minX, x);
            maxX = Math.max(maxX, x);
            allY[i] = y;
        }

        Arrays.sort(allY);

        int mean;
        if (n%2 == 0) {
            mean = Math.round(((float)(allY[n/2-1]
                + allY[n/2])) /2f);
        } else {
            mean = allY[(n-1)/2];
        }

        long cable = maxX - minX;
        for (int y : allY) {
            cable += Math.abs(y - mean);
        }

        System.out.println(cable);
    }