#include <iostream>
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//Ako ovo radi ja ne znam.
int main(int argc, char** argv) {
	int N;
	cin >> N;
	int r[N+5], c[N+5], a[N+5];
	int ans = 0;
	for(int i = 0; i < N; i++){
		cin >> r[i] >> c[i];
	}
	for(int i = 1; i <= N; i++){
		a[i-1] = i;
	}
	sort(r, r + N);
	sort(c, c + N);
	for(int i = 0; i < N; i++){
		ans += abs(a[i] - r[i]);
		ans += abs(a[i] - c[i]);
	}
	cout << ans;
	return 0;
}