#include <bits/stdc++.h>

using namespace std;

#define MAX_N 200000

int redovi[MAX_N];
int kolone[MAX_N];

int main()
{
    int N;
    scanf("%d", &N);

    for(int i = 0; i < N; i++){
        scanf("%d %d", redovi + i, kolone + i);
    }

    sort(redovi, redovi + N);
    sort(kolone, kolone + N);

    int vreme = 0;

    for(int i = 0; i < N; i++){
        if(redovi[i] != (i + 1)){
            vreme += abs(redovi[i] - (i + 1));
        }
        if(kolone[i] != (i + 1)){
            vreme += abs(kolone[i] - (i + 1));
        }
    }

    printf("%d\n", vreme);
    return 0;
}