#include #include using namespace std; int podgraf(int a, int b, int c, int d, int e) { int v1 = min(a, b) + min(d, e); int v2 = min(a + c, b) + min(d - c, e); int v3 = min(a - c, b) + min(d + c, e); return max(v1, max(v2, v3)); } int main() { int max_ship = INT32_MAX; int n; cin >> n; for (int i = 0; i < n; ++i) { int a,b,c,d,e; cin >> a >> b >> c >> d >> e; max_ship = min(max_ship, podgraf(a,b,c,d,e)); } cout << max_ship << '\n'; return 0; }