import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayDeque stack = new ArrayDeque<>(); for (int i = 0; i < n; i++) { String a = sc.next(); if (a.equals("+")) { stack.push(stack.pop() + stack.pop()); } else if (a.equals("-")) { stack.push(-stack.pop() + stack.pop()); } else { stack.push(Integer.parseInt(a)); } } System.out.println(stack.pop()); } }