import sys sys.setrecursionlimit(10000000) MOD = 10 ** 9 + 7 INF = 10 ** 15 from itertools import permutations,product,combinations_with_replacement,groupby,accumulate,combinations N = int(input()) A = list(map(int,input().split())) ans = 0 for L in product((0,1,2),repeat = N - 1): ret = A[0] for i in range(N - 1): if L[i] == 0: ret += A[i + 1] elif L[i] == 1: ret -= A[i + 1] else: ret *= A[i + 1] ans = max(ans,ret) print(ans)