N = int(input()) a = list(map(int,input().split())) s = set() s.add(a[0]) import sys if N == 2: b = a[0] c = a[1] l = [b+c,b-c,b*c] if c != 0: l.append(b//c) print(sorted(l)[-1]) exit() for i in range(1,N): t = set() b = a[i] for v in s: t.add(v+b) t.add(v*b) t.add(v-b) s = t print(sorted(s)[-1])