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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    long long zb=0;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for (int i=0;i<n;i++)
        cin >> x[i] >> y[i];
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for (int i=0;i<n;i++)
        zb=zb+abs(x[i]-(i+1))+abs(y[i]-(i+1));
    cout << zb;
}