import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons, std.typetuple; import core.bitop, std.datetime; immutable long inf = 1L<<60; long ans = -inf; void main() { int N = readln.chomp.to!int; auto a = readln.split.map!(to!long).array; long max_a = a[0], min_a = a[0]; foreach (i ; 1 .. N) { auto made = new long[](0); made ~= max_a + a[i]; made ~= max_a - a[i]; made ~= max_a * a[i]; if (a[i] != 0) made ~= max_a / a[i]; made ~= min_a + a[i]; made ~= min_a - a[i]; made ~= min_a * a[i]; if (a[i] != 0) made ~= min_a / a[i]; max_a = made.maxElement; min_a = made.minElement; } writeln(max_a); } void dfs(int N, long[] a, int idx, long value) { if (idx == N) { ans = max(ans, value); return; } dfs(N, a, idx + 1, value + a[idx]); dfs(N, a, idx + 1, value - a[idx]); dfs(N, a, idx + 1, value * a[idx]); } void readVars(T...)(auto ref T args) { auto line = readln.split; foreach(ref arg ; args){ arg = line.front.to!(typeof(arg)); line.popFront; } if(!line.empty){ writeln(line); throw new Exception("args num < input num"); } }