N = int(input())
a = [int(i) for i in input().split()]
ans = a[0]
for i in range(1,N):
    if a[i] == 0 or a[i] == 1:
        ans += a[i]
    elif a[i] < 0:
        ans -= a[i]
    else:
        if ans*a[i] > ans+a[i]:
            ans *= a[i]
        else:
            ans += a[i]
print(ans)