#include "bits/stdc++.h" #ifdef WINT_MIN #define __MAI #endif using namespace std; typedef unsigned int uint; typedef long long int ll; typedef unsigned long long int ull; #define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout< ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<>= 1, k++)s = (s << 1) | (u & 1); for (; 0>= 1)cout << (s & 1); } }template ostream& operator <<(ostream &o, const pair p) { o << "(" << p.first << ":" << p.second << ")"; return o; } #define TIME chrono::system_clock::now() #define MILLISEC(t) (chrono::duration_cast(t).count()) namespace { std::chrono::system_clock::time_point t; void tic() { t = TIME; } void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - t)); } std::chrono::system_clock::time_point tle = TIME; #ifdef __MAI void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); } #else #define safe_tle(k) ; #endif } #ifndef __MAI namespace { class MaiScanner { public: template void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'>(int& var) { input_integer(var); return *this; } MaiScanner& operator>>(long long& var) { input_integer(var); return *this; } }; } MaiScanner scanner; #else #define scanner cin #endif int width, height; int m, n; ll aa[100]; ll mindp[100]; ll maxdp[100]; int main() { int i, j, k; int x, y, a, b; scanner >> n; repeat(n) { scanner >> aa[cnt]; } fill(mindp, mindp + n, 1e18); fill(maxdp, maxdp + n, -1e18); mindp[0] = maxdp[0] = aa[0]; for (i = 1; i < n; ++i) { ll t; t = mindp[i - 1] + aa[i]; mindp[i] = min(mindp[i], t); maxdp[i] = max(maxdp[i], t); t = mindp[i - 1] - aa[i]; mindp[i] = min(mindp[i], t); maxdp[i] = max(maxdp[i], t); t = mindp[i - 1] * aa[i]; mindp[i] = min(mindp[i], t); maxdp[i] = max(maxdp[i], t); t = maxdp[i - 1] + aa[i]; mindp[i] = min(mindp[i], t); maxdp[i] = max(maxdp[i], t); t = maxdp[i - 1] - aa[i]; mindp[i] = min(mindp[i], t); maxdp[i] = max(maxdp[i], t); t = maxdp[i - 1] * aa[i]; mindp[i] = min(mindp[i], t); maxdp[i] = max(maxdp[i], t); if (aa[i] != 0) { t = mindp[i - 1] / aa[i]; mindp[i] = min(mindp[i], t); maxdp[i] = max(maxdp[i], t); t = maxdp[i - 1] / aa[i]; mindp[i] = min(mindp[i], t); maxdp[i] = max(maxdp[i], t); } } cout << maxdp[n - 1] << endl; return 0; }