N = int(input()) A = list(map(int, input().split())) Q = [A[0]] for a in A[1:]: Q2 = [] while Q: x = Q.pop() Q2.append(x * a) Q2.append(x + a) Q2.append(x - a) if a > 0: Q2.append(x//a) elif a < 0: Q2.append(-(-x)//a) Q = [min(Q2),max(Q2)] print(max(Q))