#include using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; stack st; for (int i = 0; i < n; ++i) { string s; cin >> s; if (s == "+" || s == "-") { ll b = st.top(); st.pop(); ll a = st.top(); st.pop(); if (s == "-") b *= -1; st.push(a + b); } else st.push(stoll(s)); } cout << st.top() << "\n"; return 0; }