import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; immutable int INF = 10^^9; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; auto dp = new int[][](N, 2); foreach (i; 0..N) dp[i][0] = -INF; foreach (i; 0..N) dp[i][1] = INF; dp[0][0] = max(A[0], -A[0]); dp[0][1] = min(A[0], -A[0]); foreach (i; 0..N-1) { foreach (j; 0..2) { dp[i+1][0] = max(dp[i+1][0], dp[i][j] + A[i+1]); dp[i+1][0] = max(dp[i+1][0], dp[i][j] - A[i+1]); dp[i+1][0] = max(dp[i+1][0], dp[i][j] * A[i+1]); if (A[i+1] != 0) dp[i+1][0] = max(dp[i+1][0], dp[i][0] / A[i+1]); dp[i+1][1] = min(dp[i+1][1], dp[i][j] + A[i+1]); dp[i+1][1] = min(dp[i+1][1], dp[i][j] - A[i+1]); dp[i+1][1] = min(dp[i+1][1], dp[i][j] * A[i+1]); if (A[i+1] != 0) dp[i+1][1] = min(dp[i+1][1], dp[i][j] / A[i+1]); } } writeln(dp[N-1][0]); }