#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define srt(v) sort(v.begin(),v.end())
#define srtg(v,int) sort(v.begin(),v.end(),greater<int>())
#define lb(a,v) lower_bound(v.begin(),v.end(),a)
#define ub(a,v) upper_bound(v.begin(),v.end(),a)
#define fnd(a,v) find(v.begin(),v.end(),a)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef string str;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> jedno(n);
    vector<int> drugo(n);
    for(int i=0;i<n;i++){
        cin>>jedno[i]>>drugo[i];
    }
    srt(jedno);
    srt(drugo);
    int res=0;
    for(int i=0;i<n;i++){
        res+=abs(i+1-jedno[i]);
        res+=abs(i+1-drugo[i]);
    }
    cout<<res;
    return 0;
}