#include<bits/stdc++.h>
using namespace std;
long long i,n,zbir,a[200010],b[200010];
main()
{
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i]>>b[i];
sort(a+1,a+n+1);
sort(b+1,b+n+1);
for(i=1;i<=n;i++)
zbir+=(abs(a[i]-i)+abs(b[i]-i));
cout<<zbir;
return 0;
}