#include <bits/stdc++.h>
using namespace std;
vector <int> a,b,poredjenje;
int main() {
	int n,res=0;
	cin >> n;
	for (int i=0;i<n;i++)
	{
		int ap, bp;
		cin >> ap >> bp;
		a.push_back(ap);
		b.push_back(bp);
		poredjenje. push_back(i+1);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i=0;i<n;i++)
	{
		int pom;
		pom=a[i]-poredjenje[i];
		if (pom<0) pom=-pom;
		res=res+pom;
		pom=b[i]-poredjenje[i];
		if (pom<0) pom=-pom;
		res=res+pom;
	}
	cout << res;
	return 0;
}