#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);

int n;
cin >> n;
vector<int> a;
vector<int> b;
a.push_back(0);
b.push_back(0);
for(int i = 0; i < n; i++)
{
    int x;
    int y;
    cin >> x >> y;
    a.push_back(x);
    b.push_back(y);

}

sort(a.begin(),a.end());
sort(b.begin(),b.end());

int c = 0;

for(int i = 1; i <= n; i++)
{
    c += abs(a[i] - i);
    c += abs(b[i] - i);
}


cout << c;

return 0;
}