N, T = range(int(input())), range(90000) X = [list(map(int, input().split())) for i in N] print(min([sum([abs(z[0] - x // 300 - 1) + abs(z[1] - x % 300 + 1) for z in X]) for x in T]))