n = int(input()) li = [list(map(int, input().split())) for _ in range(n)] l = [] for i in range(n): t = [] for j in range(32): x = 0 for k in range(5): if (j >> k) & 1: x += li[i][k] else: x -= li[i][k] t.append(x) l.append(t) l2 = list(zip(*l)) ma = [0] * 32 mi = [0] * 32 for j in range(32): ma[j] = max(l2[j]) mi[j] = min(l2[j]) for i in range(n): ans = 0 for j in range(32): ans = max(ans, ma[j] - l2[j][i], l2[j][i] - mi[j]) print(ans)