#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

pair<int*, int*> read(int n) {
	int* t1 = new int[n], *t2 = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d%d", t1 + i, t2 + i);
	return make_pair(t1, t2);
}

void print(int n, int* t) {
	for (int i = 0; i < n; i++)
		printf("%d ", t[i]);
}

void sort(int p, int q, int* x) {
	int i = p, j = q, pivot = x[p];
	while (i <= j) {
		for (; x[i] < pivot; i++);
		for (; x[j] > pivot; j--);
		if (i <= j) {
			swap(x[i], x[j]);
			i++;
			j--;
		}
	}

	if (i < q)
		sort(i, q, x);
	if (j > p)
		sort(p, j, x);
}

int main() {
	int n;
	cin >> n;
	pair<int*, int*> p = read(n);

	sort(0, n - 1, p.first);
	sort(0, n - 1, p.second);
	int s = 0;
	for (int i = 0; i < n; i++)
		s += abs(p.first[i] - i - 1) + abs(p.second[i] - i - 1);
	cout << s;

	delete[] p.first;
	delete[] p.second;
	return 0;
}