#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(int i = m;i >= n;--i) #define INF INT_MAX/2 using namespace std; using ll = long long; using R = double; using Data = pair>; const ll MOD = 1e9 + 7; const ll inf = 1LL << 50; struct edge { ll from; ll to; ll cost; }; ll dp[20][2]; int main() { ll n; cin >> n; vector a(n); rep(i, 0, n)cin >> a[i]; rep(i, 0, n) { ll ma = dp[i][0]; ll mi = dp[i][1]; ll temp = a[i]; vectortempv; tempv.pb(ma + temp),tempv.pb(mi + temp); if (i != 0) { tempv.pb(ma - temp), tempv.pb(mi - temp); tempv.pb(ma*temp), tempv.pb(mi*temp); if (temp != 0)tempv.pb(ma / temp), tempv.pb(mi/temp); } sort(all(tempv)); dp[i+1][0] = tempv[tempv.size() - 1]; dp[i+1][1] = tempv[0]; } cout << dp[n][0] << endl; return 0; }