#include <cstdio>
#include <iostream>
#include <vector>

class Volcanoe
{
public:
    int id;
    int x;
    int y;

    Volcanoe(int idd, int xx, int yy)
    {
        id = idd;
        x = xx;
        y = yy;
    }
};

int amount_of_volcanoes;
//Volcanoe first_volcanoe = Volcanoe(-1, -1);
//Volcanoe last_volcanoe = Volcanoe(-1, -1);
//std::vector<Volcanoe> middle_volcanoes;
std::vector<Volcanoe*> volcanoes;

void load_data()
{
    scanf("%d", &amount_of_volcanoes);

    for (int i = 0; i < amount_of_volcanoes; i++)
    {
        int x, y;
        scanf("%d %d", &x, &y);

        /*if (i == 0)
        {
            first_volcanoe = Volcanoe(x, y);
            continue;
        }

        if (i == amount_of_volcanoes - 1)
        {
            last_volcanoe = Volcanoe(x, y);
            continue;
        }*/

        volcanoes.push_back(new Volcanoe(i, x, y));
    }
}

int journey_lenght()
{
    /*std::cout << "\n";
    for (int i = 1; i < volcanoes.size(); i++)
    {
        std::cout << volcanoes[i - 1].x << " <> " << volcanoes[i].x;
        if (volcanoes[i - 1].x > volcanoes[i].x)
        {
            std::cout << " return" << '\n';
            return 2147483647;
        }
    }*/

    //int actual_x = volcanoes[0].x;
    //int actual_y = volcanoes[0].y;
    int length = 0;

    for (int i = 1; i < volcanoes.size(); i++)
    {
        length += std::abs(volcanoes[i]->x - volcanoes[i - 1]->x);
        length += std::abs(volcanoes[i]->y - volcanoes[i - 1]->y);

        //printf("x: %d, y: %d\n", volcanoes[i]);
        /*int next_x = volcanoes[i].x;
        int next_y = volcanoes[i].y;

        //if (actual_x < next_x) return 2147483647;

        length += std::abs(actual_x - next_x);
        length += std::abs(actual_y - next_y);

        actual_x = volcanoes[i].x;
        actual_y = volcanoes[i].y;*/
    }

    //std::cout << " length: " << length << '\n';

    return length;
}

int permute(int l, int r, int shortest)
{
    if (l == r)
    {
        int journey = journey_lenght();
        return (journey > shortest) ? shortest : journey;
    }

    for (int i = l; i <= r; i++)
    {
        //std::cout << "permutate\n";
        if (volcanoes[l]->x < volcanoes[i]->x) continue;

        std::swap(volcanoes[l], volcanoes[i]);

        int tmp = permute(l + 1, r, shortest);
        if (tmp < shortest) shortest = tmp;

        std::swap(volcanoes[l], volcanoes[i]);
    }

    return shortest;
}

int main()
{
    load_data();

    //std::cout << shortest_journey() << '\n';

    for (int i = 0; i < volcanoes.size() - 1; i++)
    {
        for (int j = 0; j < volcanoes.size() - 1; j++)
        {
            if (volcanoes[j]->x > volcanoes[j + 1]->x) std::swap(volcanoes[j], volcanoes[j + 1]);
        }
    }

    /*std::cout << ">>>>>>>> ";
    for (int j = 0; j < volcanoes.size(); j++)
    {
        std::cout << volcanoes[j].x << " ";
    }
    std::cout << "\n";*/

    std::cout << permute(0, volcanoes.size() - 1, 2147483647) << '\n'; // INT_MAX

    /*for (int i = 0; i < volcanoes.size(); i++)
    {
        printf("x: %d, y: %d\n", volcanoes[i]);
    }*/

    return 0;
}