#include using namespace std; int solve_mx(int a, int num){ int pl = num + a; int mi = num - a; int ml = num * a; int di; if(a == 0)di = -1e9; else di = num / a; return max(pl, max(mi, max(ml, di))); } int solve_mn(int a, int num){ int pl = num + a; int mi = num - a; int ml = num * a; int di; if(a == 0)di = 1e9; else di = num / a; return min(pl, min(mi, min(ml, di))); } int main(){ int n; cin >> n; int mx, mn; int a; cin >> a; mx = a; mn = a; for(int i = 1; i < n; i++){ cin >> a; int tmp1 = mx; mx = solve_mx(a, mx); int tmp = solve_mx(a, mn); mx = max(mx, tmp); mn = solve_mn(a, mn); tmp1 = solve_mn(a, tmp1); mn = min(mn, tmp1); //cout << mx << " " << mn << endl; } cout << max(mn, mx) << endl; }