from collections import deque

n = int(raw_input())
a = deque(map(str, raw_input().split()))

m = int(a.popleft())
b = deque([])
while True:
    if len(a) == 0:
        b.append(m)
        break
    else:
        op = a.popleft()
        if op == '+':
            m += int(a.popleft())
        else:
            b.append(m)
            m = int(a.popleft())

if len(b) == 1:
    print b.popleft()
else:
    h = b.popleft() - b.popleft()
    print h + sum(b)