#include <iostream>
#include <bits/stdc++.h>
#include <vector>

using namespace std;

int main(){
    unsigned int n;
    cin >> n;

    vector<int> X;
    vector<int> Y;

    int x,y;
    for(int i = 0 ; i < n; i++){
        cin >> x >> y;
        X.push_back(x);
        Y.push_back(y);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());

    unsigned int time = 0;
    for(int i = 1; i <= n; i++){
        time += (abs(i - X[i-1]) + abs(i - Y[i-1]));
    }

    cout << time;
    return 0;
}