#include using namespace std; #define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++) #define ALL(x) x.begin(),x.end() template bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; } template bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; } typedef long long ll; int N; ll dp [17] [2]; const ll INF = 1e18; int main() { scanf("%d",&N); vector A(N); FOR(i,0,N){ scanf("%lld",&A [i]); } FOR(i,1,N + 1){ dp [i] [0] = -INF; dp [i] [1] = INF; } dp [1] [0] = dp [1] [1] = A.front(); FOR(i,1,N) FOR(j,0,2){ chmax(dp [i + 1] [0],dp [i] [j] + A [i]); chmin(dp [i + 1] [1],dp [i] [j] + A [i]); chmax(dp [i + 1] [0],dp [i] [j] - A [i]); chmin(dp [i + 1] [1],dp [i] [j] - A [i]); chmax(dp [i + 1] [0],dp [i] [j] * A [i]); chmin(dp [i + 1] [1],dp [i] [j] * A [i]); if(A [i]){ chmax(dp [i + 1] [0],dp [i] [j] / A [i]); chmin(dp [i + 1] [1],dp [i] [j] / A [i]); } } printf("%lld\n",dp [N] [0]); return 0; }