I,R=input,range N,T=R(int(I())),R(90000) X=[list(map(int,I().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]))