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) Q = Q2 print(max(list(Q)))