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

int solve(vector<int> a) {

    int n = a.size(), ans = 0;

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

    for (int i = 0; i < n; i++)
        ans += abs(a[i] - (i+1));

    return ans;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    vector<int> a(n), b(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    cout << solve(a) + solve(b) << '\n';

}