N = int(input()) X, Y = [], [] for i in range(N): x, y = map(int, input().split()) X.append(x) Y.append(y) Mx = max(X) My = max(Y) ans = float("inf") for j in range(Mx+1): for k in range(My+1): tmp = 0 for l in range(N): tmp += abs(X[l] - j) + abs(Y[l] - j) ans = min(ans, tmp) print(ans)