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; dfs(N, a, 1, a[0]); writeln(ans); } 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"); } }