N = gets.to_i a = gets.split.map(&:to_i) OP = [:+, :-, :*, :/] ans = a.inject([0, 0]) {|memo, x| d = memo.product(OP).map {|v, o| if not (x == 0 and o == :/) v.send(o, x) else 0 end } [d.min, d.max] }.max puts ans