#include #include #include void solve() { int n; std::cin >> n; std::vector stk; while (n--) { std::string s; std::cin >> s; if (s == "+") { int b = stk.back(); stk.pop_back(); int a = stk.back(); stk.pop_back(); stk.push_back(a + b); } else if (s == "-") { int b = stk.back(); stk.pop_back(); int a = stk.back(); stk.pop_back(); stk.push_back(a - b); } else { stk.push_back(std::stoi(s)); } } std::cout << stk.front() << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }