#include <bits/stdc++.h>

using namespace std;

int timer(int a[], int b[], int n)
{
    int time = 0;
    for(int k = 0; k < n; k++)
    {
        if (a[k] != k+1)
            time += abs(a[k] - (k + 1));
        if (b[k] != k+1)
            time += abs(b[k] - (k + 1));
    }
    return time;
}

int main()
{
    int n;
    cin >> n;
    int a[n], b[n];

    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    sort(a, a+n);
    sort(b, b+n);

    cout << timer(a, b, n);

    return 0;
}