N = int(input()) A = [0]+list(map(int,input().split())) def sgn(x): if x>0: return 1 elif x<0: return -1 else: return 0 dp = [[0,0] for _ in range(N+1)] dp[1] = [A[1],A[1]] for i in range(2,N+1): a = A[i] if a!=0: dp[i][0] = max(dp[i-1][0]+a,dp[i-1][0]-a,dp[i-1][0]*a,abs(dp[i-1][0])//abs(a)*sgn(dp[i-1][0])*sgn(a),dp[i-1][1]+a,dp[i-1][1]-a,dp[i-1][1]*a,abs(dp[i-1][1])//abs(a)*sgn(dp[i-1][1])*sgn(a)) dp[i][1] = min(dp[i-1][0]+a,dp[i-1][0]-a,dp[i-1][0]*a,abs(dp[i-1][0])//abs(a)*sgn(dp[i-1][0])*sgn(a),dp[i-1][1]+a,dp[i-1][1]-a,dp[i-1][1]*a,abs(dp[i-1][1])//abs(a)*sgn(dp[i-1][1])*sgn(a)) else: dp[i][0] = max(dp[i-1][0],0,dp[i-1][1]) dp[i][1] = min(dp[i-1][0],0,dp[i-1][1]) print(dp[N][0])