#N,L,R=map(int, input().split()) #A=list(map(int, input().split())) N=int(input()) C=[];D={} for j in range(2**5): B=[];D[j]=[] for k in range(5): if j%2==1: B.append(1) else: B.append(-1) j//=2 C.append(B) A=[];T=[[]for i in range(N)];D=[[]for i in range(32)] for i in range(N): a,b,c,d,e=map(int, input().split()) A.append((a,b,c,d,e)) for now in range(32): x,y,z,w,v=C[now] cc=a*x+b*y+c*z+d*w+e*v T[i].append(cc) if i==0: D[now].append(cc) D[now].append(cc) else: D[now][0]=max(D[now][0],cc) D[now][1]=min(D[now][1],cc) for i in range(N): ans=[] for j in range(32): d=abs(D[j][0]-T[i][j]);e=abs(D[j][1]-T[i][j]) ans.append(d) ans.append(e) print(max(ans))