n = int(input()) A = input().split() ans = [] for a in A: if a == "+": x = ans.pop() y = ans.pop() ans.append(x + y) elif a == "-": x = ans.pop() y = ans.pop() ans.append(y - x) else: ans.append(int(a)) print(*ans)