#include<bits/stdc++.h> using namespace std; int a[3000000]; int main(){ int n;cin>>n; int top=0,x;string s; for(int i=0;i<n;i++){ cin>>s; if(s=="push")cin>>x,a[top++]=x;//输入 else if(top==0)cout<<"error"<<endl;//判断栈空 else if(s=="pop")cout<<a[--top]<<endl;//输出栈顶并弹出 else cout<<a[top-1]<<endl;//输出栈顶 } return 0; }