import java.util.Scanner; import java.util.Stack; public class HelloWorld { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); String[] strs = sc.nextLine().split(" "); sc.close(); Stack stack = new Stack(); for (String str : strs) { if (str.equals("+")) { stack.push(stack.pop() + stack.pop()); } else if (str.equals("-")) { stack.push(-stack.pop() + stack.pop()); } else { stack.push(Integer.parseInt(str)); } } System.out.println(stack.pop()); } }