#define _GLIBCXX_DEBUG #define ll long long #include using namespace std; using Graph = vector>; int main(){ int N; cin >> N; vector A; for(int i = 0; i < N; i++){ string S; cin >> S; if(S != "+" and S != "-"){ int s = stoi(S); A.push_back(s); }else{ if(S == "+"){ int a = (int)A.size(); int X = A[a-2] + A[a-1]; A.pop_back(); A.pop_back(); A.push_back(X); }else{ int a = (int)A.size(); int X = A[a-2] - A[a-1]; A.pop_back(); A.pop_back(); A.push_back(X); } } } cout << A[0] << endl; }