#include using namespace std; #define int long long #define all(v) begin(v), end(v) #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++) template void chmin(T1 &a, T2 b){if(a>b)a=b;} template void chmax(T1 &a, T2 b){if(a; using tint = tuple; using vint = vector; const int inf = 1LL << 55; const int mod = 1e9 + 7; int ans = 0; int dfs(int idx, vint& a) { if(idx == a.size()-1) return a[idx]; int res = -inf; rep(i, 3) { if(i == 0) { chmax(res, dfs(idx+1, a) + a[idx]); } else if(i == 1) { chmax(res, dfs(idx+1, a) - a[idx]); } else if(i == 2) { chmax(res, dfs(idx+1, a) * a[idx]); } } return res; } signed main() { cin.tie(0); ios_base::sync_with_stdio(0); cout << fixed << setprecision(12); int N; cin >> N; vint a(N); rep(i, N) cin >> a[i]; reverse(all(a)); cout << dfs(0, a) << endl; return 0; }