#include #include #include #include using namespace std; int main(){ int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } stack st; for (int i = 0; i < N; i++){ if (A[i] == "+" || A[i] == "-"){ int b = st.top(); st.pop(); int a = st.top(); st.pop(); if (A[i] == "+"){ st.push(a + b); } if (A[i] == "-"){ st.push(a - b); } } else { st.push(stoi(A[i])); } } cout << st.top() << endl; }