#include <bits/stdc++.h>

using namespace std;


int n, r[200010], c[200010];
long long ress=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    for (int i=0; i<n; i++)
        cin>>r[i]>>c[i];

    sort (r, r+n);
    sort(c, c+n);

    for (int i=0; i<n; i++)
    {
        //cout<<r[i]<<" "<<i+1<<" "<<c[i]<<endl;
        ress+=abs(r[i]-i-1);
        ress+=abs(c[i]-i-1);
    }
    cout<<ress;
}