N=int(input()) stack=[] for a in input().split(): if a=="+": u=stack.pop() v=stack.pop() stack.append(v+u) elif a=='-': u=stack.pop() v=stack.pop() stack.append(v-u) else: stack.append(int(a)) print(stack.pop())