#include using namespace std; int main() { int N; cin >> N; stack s; for (int i = 0; i < N; i++) { string str; cin >> str; if (str != "+" && str != "-") s.push(stoi(str)); else { int tmp1 = s.top(); s.pop(); int tmp2 = s.top(); s.pop(); if (str == "+") s.push(tmp2 + tmp1); else s.push(tmp2 - tmp1); } } cout << s.top() << endl; }