// // Created by cteam37 on 10/19/24. // #include using namespace std; int main() { int numOfInput; cin >> numOfInput; int32_t min = INT32_MAX; for (int i = 0; i < numOfInput; ++i) { int a,b,c,d,e; cin >> a; cin >> b; cin >> c; cin >> d; cin >> e; /*int downMiddle = 0; int upMiddle = 0; if(b > a) { downMiddle += b; } else downMiddle += a;*/ int tmp = std::max(std::max(std::min(a,b) + std::min(d,e), std::min(a+c, b) + std::min(d-c, e)), std::min(a-c, b) + std::min(d+c, e)); if(tmp < min) min = tmp; } cout << min << endl; return 0; }