#include <bits/stdc++.h>

using namespace std;

int main()
{
    int i, n, br_sekundi = 0; scanf("%d", &n);
    vector<int> r(n), c(n);

    for(i = 0; i < n; ++i) scanf("%d%d", &(r[i]), &(c[i]));

    sort(r.begin(), r.end());
    sort(c.begin(), c.end());

    for(i = 0; i < n; ++i) br_sekundi += (abs(r[i] - (i + 1)) + abs(c[i] - (i + 1)));

    printf("%d", br_sekundi);

    return 0;
}