import java.util.ArrayList;
	import java.util.Collections;
	import java.util.Scanner;

	public class Main {

		
		boolean compare(int a, int b) {
			
			return a>=b;
			
		}
		
		
		public static void main(String[] args) {
			
			
			

			Scanner s = new Scanner(System.in);
			
			
			
			int n = s.nextInt(), zbir = 0;
			ArrayList<Integer> x = new ArrayList<Integer>();
			ArrayList<Integer> y = new ArrayList<Integer>();
			
			for(int i = 0; i < n; i++) {
				
				x.add(s.nextInt());
				y.add(s.nextInt());
				
			}
			
			Collections.sort(x, Collections.reverseOrder());
			Collections.sort(y, Collections.reverseOrder());
			
			
			for(int i = 0; i < n ; i++) {
				
				zbir += Math.abs((x.get(i)-n+i));
				zbir += Math.abs((y.get(i)-n+i));
				
			}
			
			System.out.println(zbir);
			
		}

	}