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