//* Problem  : 2953 - TENKICI
//* Contest  : acm.tju.edu.cn
//* Origin   : 
//* Type     : Solution
//* Date     : 2008.04.29
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0
//* Algoritm : 

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <iostream>
using namespace std;
#define int64 long long

int n, res;

int x[512], y[512];

int cmp_f(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int count(int *a)
{
	qsort(a, n, sizeof(a), cmp_f);
	int res = 0;
	for (int i = 0; i < n; i++)
		res += abs(a[i] - (i + 1));
	return res;
}

int main()
{
#ifdef _DEBUG
	freopen("1366", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0 ; i < n; i++)
		scanf("%d%d", &x[i], &y[i]);
	res = count(x) + count(y);
	printf("%d\n", res);
	return 0;
}
