N=int(input()) a=list(map(int,input().split())) v1=a[0] v2=a[0] for i in range(1,N): if a[i]!=0: v1=max(v1+a[i],v1-a[i],v1*a[i],v2*a[i],v2//a[i]) v2=min(v2+a[i],v2-a[i],v1*a[i],v2*a[i],v1//a[i]) else: v1=max(v1+a[i],v1-a[i],v1*a[i],v2*a[i]) v2=min(v2+a[i],v2-a[i],v1*a[i],v2*a[i]) print(v1)