#include using namespace std; #ifdef _RUTHEN #include #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; V> A(5, V(N)); rep(i, N) rep(j, 5) cin >> A[j][i]; const int M = 5, M2 = 1 << 5; const long long INF = 1LL << 60; V S(M2, -INF); rep(i, N) { rep(bit, M2) { long long c = 0; rep(j, 5) { if (bit >> j & 1) { c += A[j][i]; } else { c -= A[j][i]; } } S[bit] = max(S[bit], c); } } rep(i, N) { long long ans = -INF; rep(bit, M2) { long long c = 0; rep(j, 5) { if (bit >> j & 1) { c -= A[j][i]; } else { c += A[j][i]; } } ans = max(ans, c + S[bit]); } cout << ans << '\n'; } return 0; }