#include <bits/stdc++.h>

using namespace std;
vector <int> v1;
vector <int> v2;

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x,y;
        cin >> x >> y;
        v1.push_back(x);
        v2.push_back(y);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    long long s = 0LL;
    int j = 1;
    for(auto x:v1)
    {
        s += 1LL*abs(j-x);
        j++;
    }
    j = 1;
    for(auto x:v2)
    {
        s += 1LL*abs(j-x);
        j++;
    }
    cout << s;
    return 0;
}