import sys readline = sys.stdin.readline N = int(readline()) A, B, C, D, E = [0] * N, [0] * N, [0] * N, [0] * N, [0] * N F = [] for i in range(N): A[i], B[i], C[i], D[i], E[i] = map(int, readline().split()) F.append((A[i], B[i], C[i], D[i], E[i], i)) L = [] for i in range(5): F.sort(key=lambda x : x[i]) L.append(F[0][-1]) L.append(F[-1][-1]) for i in range(N): ans = 0 for a in L: ans = max(ans, abs(A[i] - A[a]) + abs(B[i] - B[a]) + abs(C[i] - C[a]) + abs(D[i] - D[a]) + + abs(E[i] - E[a])) print(ans)