//Failure will never overtake me if my determination to succeed is strong enough
#include <bits/stdc++.h>

using namespace std;

int a[300005], b[300005];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }

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

    long long rez = 0;

    for(int i = 1; i <= n; i++)
    {
        rez += abs((long long)i-(long long)a[i-1])+abs((long long)i-(long long)b[i-1]);
    }

    cout << rez;


}