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

int main() {
    int n;
    scanf ("%d",&n);
    int a,b;
    vector<int> x;
    vector<int> y;
    for (int i=0; i<n; i++) {
        scanf("%d %d",&a,&b);
        x.push_back(a);
        y.push_back(b);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    int res=0;
    for (int i=1;i<=n;i++) {
        res+=abs(x[i-1]-i);
        res+=abs(y[i-1]-i);
    }
    printf("%d",res);
}