N = int(input()) A = [list(map(int, input().split())) for _ in range(N)] ans = 10**18 for i in range(N): p = A[i] for j in range(N): q = A[j] r = [(x+y)//2 for x, y in zip(p, q)] ct = 0 for k in range(N): for n in range(2): ct += abs(r[n]-A[k][n]) ans = min(ans, ct) print(ans)