N = int(input()) A = list(map(str, input().split())) Numbers = [] for i in range(N): try: Numbers.append(int(A[i])) except: Second = Numbers.pop() First = Numbers.pop() if A[i] == "+": Numbers.append(First + Second) else: Numbers.append(First - Second) print(Numbers.pop())