from bisect import * N = int(input()) A = list(map(int, input().split())) Q = {A[0]} for a in A[1:]: Q2 = set() while Q: x = next(iter(Q)) Q.remove(x) Q2.add(x + a) Q2.add(x - a) Q2.add(x * a) if a != 0: Q2.add(x // a) Q2 = sorted(list(Q2)) Q = set() Q.add(Q2[0]) Q.add(Q2[-1]) if Q2[-1] > 0: Q.add(bisect_left(Q2,0)) if Q2[0] < 0: Q.add(bisect_left(Q2,0) - 1) print(max(list(Q)))