#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]; } int ans = -INF; for(int i = 0; i < 1 << n; i++){ vector dp(100, -INF); for(int j = 0; j < n; j++){ if(j == 0){ dp[j+1] = a[j]; continue; } if(i >> j & 1){ dp[j+1] = dp[j] - a[j]; }else { dp[j+1] = max(dp[j+1], dp[j] + a[j]); dp[j+1] = max(dp[j+1], dp[j] * a[j]); if(a[j] != 0) dp[j+1] = max(dp[j+1], dp[j] / a[j]); } } ans = max(ans, dp[n]); } cout << ans << endl; return 0; }