n = int(input())
a = list(map(str,input().split()))
dp = [[-float("inf")] *4 for i in range(n+1)]
dp[0][0] = 0
for i in range(len(a)):
    b = i//2+1
    if a[i] == "-":
        tmp = [-float("inf"),0,0,0]
        for j in range(3):
            tmp[j+1] = dp[b][j]
        dp[b] = tmp
        continue
    elif a[i] == "+":
        continue
    for j in range(4):
        for k in range(3):
            if j >= k:
                dp[b][k] = max(dp[b][k],dp[b-1][j]+((-1)**j)*int(a[i]))
print(dp[n][0])
    