#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) for(int i=0;i<(n);i++) typedef long long ll; typedef vector vi; typedef vector vvi; #define pii pair #define piii pair #define mp make_pair #define pb push_back #define ALL(a) (a).begin(),(a).end() #define FST first #define SEC second const int INF = (INT_MAX/2); const double eps = 1e-14; const double PI = M_PI; #define DEB cout<<"!"<> N; ll now_max,now_min; REP(i,N){ ll a; cin >> a; if(i==0){ now_max = a; now_min = a; }else{ ll t_now_max = max({now_max+a,now_max-a,a==0?(0):(now_max/a),now_max*a,now_min*a,a==0?(0):(now_min/a)}); now_min = min({now_min-a,now_min+a,now_min*a,a==0?(now_min):now_min/a,now_max*a,now_max+a,now_max-a}); now_max = t_now_max; } } cout << now_max << endl; return 0; }