#include<bits/stdc++.h>
#define maxn 200005
#define pb push_back
#define ll long long
using namespace std;

int n;
int x[maxn];
int y[maxn];


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

    cin>>n;
    for(int i=1;i<=n;i++)cin>>x[i]>>y[i];

    sort(x+1,x+n+1);
    sort(y+1,y+n+1);

    ll sol = 0;
    for(int i=1;i<=n;i++)
    {
        sol += abs(x[i] - i);
        sol += abs(y[i] - i);
    }

    cout<<sol<<"\n";
    return 0;
}