#include<bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;
const int N = 200000;

pair<int,int> niz[N+10];
int xKoor[N+10];
int yKoor[N+10];

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

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        niz[i] = mp(a,b);
        xKoor[i] = a;
        yKoor[i] = b;
    }
    sort(xKoor, xKoor + n);
    sort(yKoor, yKoor + n);
    ll sum = 0;
    for(int i = 0; i < n; i++)
        sum += abs(i - xKoor[i]);
    for(int i = 0; i < n; i++)
        sum += abs(i - yKoor[i]);
    cout << sum;



    return 0;
}