#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

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);
    int brojac = 0;
    for (int i = 0; i<n; i++)
    {
        if (a[i]!=i+1) brojac = brojac + abs((i+1)-a[i]);
        if (b[i]!=i+1) brojac = brojac + abs((i+1)-b[i]);
    }
    cout <<brojac;
    return 0;
}