#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void) {
    int N;
    cin >> N;
    ll dp[N][2];
    int a;
    cin >> a;
    dp[0][0] = a;
    dp[0][1] = a;
    for (int i=1; i<N; i++) {
        cin >> a;
        if (a < 0) {
            dp[i][0] = max(dp[i-1][0] - a, dp[i-1][1] * a);
            dp[i][1] = min(dp[i-1][0] * a, dp[i-1][1] + a);
        } else {
            dp[i][0] = max(dp[i-1][0] + a, dp[i-1][0] * a);
            dp[i][1] = min(dp[i-1][1] - a, dp[i-1][1] * a);
        }
            dp[i][0] = max(dp[i][0], dp[i-1][1]/ a);
            dp[i][1] = max(dp[i][1], dp[i-1][0]/ a);
    }
    cout << dp[N-1][0] << endl;
    return 0;
}