import sys
input = sys.stdin.readline

N = int(input())
terms = [[]] # マイナス区切り
op = '+'
for x in input().rstrip().split():
    if x in '+-':
        op = x
        continue
    x = int(x)
    if op == '+':
        terms[-1].append(x)
    else:
        terms.append([x])

# 何をマイナスにするか

min_minus = 10 ** 18
first_sum = 0
for t in terms[1:]:
    x = first_sum + sum(t)
    if x < min_minus:
        min_minus = x
    first_sum += t[0]

answer = sum(sum(t) for t in terms)
if len(terms) > 1:
    answer -= 2 * min_minus

print(answer)