#include <iostream>
#include <stdio.h>
#include <algorithm>
#define MAX 20000

int rn[MAX];
int cn[MAX];

using namespace std;

void proveri(int n, int* br, int niz[])
{
    for(int i = 0; i < n; ++i)
    {
        *br += abs((i+1) - niz[i]);
    }
}

int main()
{
    int n, i;
    int br = 0;
    scanf("%i", &n);
    for(i = 0; i < n; ++i)
    {
        scanf("%i %i", &rn[i], &cn[i]);
    }

    sort(rn, rn+n);
    sort(cn, cn+n);

    proveri(n, &br, rn);
    proveri(n, &br, cn);
    printf("%i", br);
}