n = int(input())
ipt = input().split()
a = [int(ipt[i]) for i in range(0, 2*n+1,2)] + [0]
opr = [''] + [ipt[i] for i in range(1, 2*n, 2)] + ['-']
max_v = a[0]
for i in range(1,n):
    if opr[i] == '+':
        max_v += a[i]
    else:
        max_v -= a[i]

s = sum(a)
cur = 0
for i in range(1,n+1):
    if opr[i] == '-':
        if cur != 0:
            max_v = max(max_v, s-2*cur)
        cur = a[i]
    else:
        if cur != 0:
            cur += a[i]
print(max_v)