#include <iostream>

using namespace std;

int p[200001], q[200001];
static bool pp[200001], qq[200001];

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    long long ppp = 0, qqq = 0, r = 0, c = 0;

    cin >> n;
    for( int i = 1; i <= n; i++ )
    {
        cin >> p[i] >> q[i];
        if(pp[p[i]])
            ppp += p[i];
        else
            pp[p[i]] = 1;
        if(qq[q[i]])
            qqq += q[i];
        else
            qq[q[i]] = 1;
    }

    for( int i = 1; i <= n; i++ )
    {
        if( !pp[i] )
            r += i;
        if( !qq[i] )
            c += i;
    }

    cout << abs( r - ppp ) + abs( c - qqq );

    return 0;
}