using System.Collections.Generic; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); getAns(n); } static void getAns(int n) { var st = new Stack(); string[] line = Console.ReadLine().Trim().Split(' '); for (int i = 0; i < n; i++) { if (line[i] == "+") { var w = st.Pop() + st.Pop(); st.Push(w); } else if (line[i] == "-") { var w = -st.Pop() + st.Pop(); st.Push(w); } else st.Push(int.Parse(line[i])); } Console.WriteLine(st.Pop()); } }