

DEBUG = False

N = int(input())

def get_dist(a, b):
    dist = abs(a[0] - b[0]) + abs(a[1] - b[1])
    if DEBUG:
        print(f"{a} -> {b} = {dist}")
    return dist

def get_col_sum(col):
    col_sum = abs(col[0][1] - col[-1][1])
    return col_sum

volcs = []
for n in range(N):
    a, b = input().split(' ')
    a, b = int(a), int(b)
    # print(a, b)
    volcs.append((b,a))

# sort left to right

# sort up to down
volcs.sort(key=lambda tup : tup[1]) # top down
volcs.sort(key=lambda tup : tup[0])

if DEBUG:
    print("sorted: ", volcs)

cols_list = []

curr_col = [volcs[0]]
for i in range(1, len(volcs)):
    if curr_col[0][0] == volcs[i][0]:
        curr_col.append(volcs[i])
    else:
        cols_list.append(curr_col)
        curr_col = [volcs[i]]

cols_list.append(curr_col)

if DEBUG:
    print("cols_list: ")
    print(cols_list)

res = 0

graph = [[0, 0] for _ in range(len(cols_list))]

first_col_sum = get_col_sum(cols_list[0])
# print(first_col_sum)
graph[0][0] = first_col_sum
graph[0][1] = first_col_sum


for i in range(0, len(cols_list)-1):
    # 1. path to top one

    ## from graph[i][0]
    first_price = graph[i][0] + get_dist(cols_list[i][0], cols_list[i+1][0])

    ## from graph[i][1]
    second_price = graph[i][1] + get_dist(cols_list[i][-1], cols_list[i+1][0])

    graph[i+1][0] = min(first_price, second_price)

    # 2. path to bottom one

    ## from graph[i][0]
    first_price = graph[i][0] + get_dist(cols_list[i][0], cols_list[i+1][-1])

    ## from graph[i][1]
    second_price = graph[i][1] + get_dist(cols_list[i][-1], cols_list[i+1][-1])

    graph[i+1][1] = min(first_price, second_price)

# print(graph)

res = max(graph[-1][0],graph[-1][1])

print(res)
exit(0)


for i in range(len(cols_list)-1):
    # compute cost of current col
    curr_col = cols_list[i]
    next_col = cols_list[i+1]
    # col_sum = abs(curr_col[0][1] - curr_col[-1][1])
    col_sum = get_col_sum(curr_col)
    res += col_sum

    # compute dist to next col
    f2f = get_dist(curr_col[0], next_col[0])
    f2s = get_dist(curr_col[0], next_col[-1])
    s2f = get_dist(curr_col[-1], next_col[0])
    s2s = get_dist(curr_col[-1], next_col[-1])

    res += min(f2f, f2s, s2f, s2s)
    # print("col_sum: ", col_sum)

curr_col = cols_list[-1]
# col_sum = abs(curr_col[0][1] - curr_col[-1][1])
col_sum = get_col_sum(curr_col)
res += col_sum

# print("res: ", res)
print(res)

