N = int(input()) A = list(input().split()) B = [] for a in A: if a == '+': b = B.pop() a = B.pop() B += [a+b] elif a == '-': b = B.pop() a = B.pop() B += [a-b] else: B += [int(a)] print(*B)