using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zadatak_3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;

            n = Convert.ToInt32(Console.ReadLine());

            string[] unos = new string[2];
            int[] niz = new int[n];
            int[] niz1 = new int[n];
            int[] pomocni = new int[n];
            int s = 0;

            for (int i = 0; i < n; i++)
            {
                unos = Console.ReadLine().Split(' ');
                niz[i] = Convert.ToInt32(unos[0]);
                niz1[i] = Convert.ToInt32(unos[1]);
            }

            for (int i = 0; i < n; i++)
            {
                pomocni[i] = i + 1;
            }

            Array.Sort(niz);
            Array.Sort(niz1);

            for (int i = 0; i < n; i++)
            {
                if (niz[i] != pomocni[i])
                {
                    s = s + (Math.Abs(niz[i] - pomocni[i]));
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (niz1[i] != pomocni[i])
                {
                    s = s + (Math.Abs(niz1[i] - pomocni[i]));
                }
            }

            Console.Write(s);
        }
    }
}