#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int n;
int x[200002],y[200002];
int resi(int a[200002])
{
    int pivot=1;
    int res=0;
    sort(a,a+n);
  /*  for(int i=0;i<n;i++)
        cout<<a[i]<<" ";
    cout<<endl;*/
    for(int i=0;i<n && pivot<=n;i++)
    {
        //cout<<a[i]<<" "<<pivot<<" "<<res<<endl;
        if(a[i]!=pivot)
        {
            res+=abs(a[i]-pivot);
            pivot++;
        }
        else
            pivot++;
    }
    return res;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%d%d",&x[i],&y[i]);
    cout<<resi(x)+resi(y);
}