n = int(input()) arr = [[0]*n for _ in range(16)] for i in range(n): a = list(map(int, input().split())) for bit in range(1 << 4): amo = a[0] for j in range(4): if bit & (1 << j): amo += a[j+1] else: amo -= a[j+1] arr[bit][i] = amo mx = [0]*16 mn = [0]*16 for i in range(16): mx[i], mn[i] = max(arr[i]), min(arr[i]) for j in range(n): res = 0 for i in range(16): res = max(res, mx[i]-arr[i][j], arr[i][j]-mn[i]) print(res)