n = input()
code = raw_input().split()
a = int(code[0]); b = c = -10**18
for op, v in zip(code[1::2], map(int,code[2::2])):
    if op is "+":
        b = max(b-v, c+v)
        c += v
        a = max(a+v, b)
    else:
        c = max(b+v, c-v)
        a = b = max(a-v, c)
print max(a, b, c)