

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

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

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])
    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])
res += col_sum

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

