#include #include #include #include #include #include #include #include #include #include #include #include #define ALL(g) (g).begin(),(g).end() #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define pb push_back using namespace std; typedef long long ll; typedef pair P; const int mod=1e9+7; const int INF=1<<30; const int MAX_N=100001; int main(){ int N; cin >> N ; ll ma=0,mi=0,a; cin >> a ; ma=mi=a; REP(i,1,N){ cin >> a ; ll temp=mi; if(a){ ma=max(max(ma+a,ma*a),max(ma-a,max(mi*a,ma/a))); mi=min(min(mi+a,mi-a),min(mi/a,min(mi*a,temp*a))); }else{ ma=max(ma,0LL); mi=min(mi,0LL); } //cout << ma << " "<