n=int(input()) l=input().split() for i in range(n): if l[i] in "+-": l[i]=str(eval(l[i-2]+l[i]+l[i-1])) l[:i]=['','']+l[:i-2] print(l[n-1])