#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long const int INF = 1LL << 60; signed main(){ int n; cin >> n; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } static int dp[21][2]; for(int i = 0; i < n; i++){ dp[i][0] = INF; dp[i][1] = -INF; } dp[0][0] = dp[0][1] = a[0]; for(int i = 1; i < n; i++){ dp[i][0] = min(dp[i][0], dp[i-1][0] + a[i]); dp[i][0] = min(dp[i][0], dp[i-1][0] - a[i]); dp[i][0] = min({dp[i][0], dp[i-1][0] * a[i], dp[i-1][1] * a[i]}); if(a[i] != 0) dp[i][0] = min(dp[i][0], dp[i-1][0] / a[i]); dp[i][1] = max(dp[i][1], dp[i-1][1] + a[i]); dp[i][1] = max(dp[i][1], dp[i-1][0] - a[i]); dp[i][1] = max({dp[i][1], dp[i-1][1] * a[i], dp[i-1][0] * a[i]}); if(a[i] != 0) dp[i][1] = max(dp[i][1], dp[i-1][1] / a[i]); //cout << dp[i][0] << " " << dp[i][1] << endl; } cout << max(dp[n-1][0], dp[n-1][1]) << endl; return 0; }