import sys try: import os f = open('input.txt', 'r') sys.stdin = f except FileNotFoundError: None from math import sqrt, ceil input=lambda: sys.stdin.readline().strip() n=int(input()) s=list(map(str,input().split())) now=0 # def expr(): # global now # ans= term() # while now=n: # return 0 # elif n-2 <= now: # # print(s[now],now) # x = int(s[now]) # now +=1 # return x # elif s[now].isdecimal() and s[now+1].isdecimal() and s[now+2] in "+-": # x = int(s[now]) # y = int(s[now+1]) # op = s[now+2] # now+=3 # if op=="+": return x+y # return x-y # # elif all([s[i].isdecimal() for i in range(now,now+3)]): # else: # # x = int(s[now]); now+=1 # y = term() # op = s[now] # now+=1 # if op=="+":return x+y # return x-y # # now+=1 # # return int(s[now]) # # # # print(expr()) def expr(): global now x = term() ans = x while now=n: return 0 elif n-2 <= now: # print(s[now],now) x = int(s[now]) now +=1 return x elif s[now].isdecimal() and s[now+1].isdecimal() and s[now+2] in "+-": x = int(s[now]) y = int(s[now+1]) op = s[now+2] now+=3 # print("term-d",x,y,op,now) if op=="+": return x+y return x-y # elif all([s[i].isdecimal() for i in range(now,now+3)]): else: x = int(s[now]) now+=1 return x print(expr())