N = int(input()) As = list(map(int, input().split())) low = high = As[0] for a in As[1:]: vals = [high * a, high + a, high - a, low * a, low + a, low - a] high = max(vals) low = min(vals) print(high)