N = int(input()) A = list(map(int,input().split())) INF = 1 << 120 dp = [A[0], A[0]] # 正の方向、負の方向の最大値 for i in range(1, N): new_dp = [-INF, INF] new_dp[0] = max(new_dp[0], dp[0] * A[i], dp[0] + A[i], dp[0] - A[i], dp[1] * A[i], dp[1] + A[i], dp[1] - A[i]) if A[i] != 0: new_dp[0] = max(new_dp[0], dp[0] // A[i]) new_dp[1] = min(new_dp[1], dp[0] * A[i], dp[0] + A[i], dp[0] - A[i], dp[1] * A[i], dp[1] + A[i], dp[1] - A[i]) if A[i] != 0: new_dp[1] = min(new_dp[1], dp[0] // A[i]) dp = new_dp print(dp[0])