n = int(input())
ipt = input().split()
node = [int(ipt[0])]
plus = n-1
while plus > 0 and ipt[2*plus] == '+':
    node[0] += int(ipt[2*plus+1])
    plus -= 1
for i in range(plus):
    if ipt[2*i+1] == '+':
        node[-1] += int(ipt[2*i+2])
    else:
        node.append(int(ipt[2*i+2]))
if len(node) == 1:
    print(node[0])
else:
    print(sum(node) - 2*node[1])