#include <bits/stdc++.h>

using namespace std;

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

    int32_t N;
    uint64_t r_best = 0, c_best = 0;

    cin >> N;

    int32_t r[N], c[N];

    for(int32_t i = 0; i < N; i++){
        cin >> r[i] >> c[i];
    }

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

    for(int32_t i = 1; i <= N; i++){
        r_best += abs(r[i - 1] - i);
        c_best += abs(c[i - 1] - i);
    }

    cout << r_best + c_best;
}