#include <bits/stdc++.h>
using namespace std;

int a[200005];
int b[200005];

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    int res = 0;
    for(int i = 0; i < n; ++i){
        res += abs(a[i] - (i + 1));
        res += abs(b[i] - (i + 1));
    }

    cout << res << "\n";
    return 0;
}