#include #include #include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} ll d(int x,int y,vector>&A){ ll dist=0; rep(i,5)dist+=abs(A[x][i]-A[y][i]); return dist; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; vector>A(n,vector(5)); rep(i,n)rep(j,5)cin>>A[i][j]; ll ans=0; vectorM(1<<5,-1LL<<60),m(1<<5,1LL<<60); rep(i,n){ rep(s,1<<5){ ll p=0; rep(j,5){ if(s>>j&1){ p+=A[i][j]; }else{ p-=A[i][j]; } } chmax(M[s],p); chmin(m[s],p); } } rep(i,n){ ll ans=-1LL<<60; rep(s,1<<5){ ll p=0; rep(j,5){ if(s>>j&1){ p+=A[i][j]; }else{ p-=A[i][j]; } } chmax(ans,M[s]-p); chmax(ans,p-m[s]); } cout<