#include using namespace std; using ll = long long; int main(){ int n; cin >> n; ll a[n], dp[n][2]; for(int i = 0; i < n; i++){ cin >> a[i]; dp[i][0] = 1ll << 60; dp[i][1] = -(1ll << 60); } dp[0][0] = dp[0][1] = a[0]; for(int i = 1; i < n; i++){ for(int j = 0; j < 2; j++){ dp[i][0] = min(dp[i][0], dp[i - 1][j] + a[i]); dp[i][0] = min(dp[i][0], dp[i - 1][j] - a[i]); dp[i][0] = min(dp[i][0], dp[i - 1][j] * a[i]); if(a[i]) dp[i][0] = min(dp[i][0], dp[i - 1][j] / a[i]); dp[i][1] = max(dp[i][1], dp[i - 1][j] + a[i]); dp[i][1] = max(dp[i][1], dp[i - 1][j] - a[i]); dp[i][1] = max(dp[i][1], dp[i - 1][j] * a[i]); if(a[i]) dp[i][1] = max(dp[i][1], dp[i - 1][j] / a[i]); } } cout << dp[--n][1] << endl; }