include [HTML_REMOVED]
using namespace std;
const int N = 100010;
int stk[N],tt;
int main()
{
int x,i,n;
scanf(“%d”,&n);
for(i=0;i[HTML_REMOVED]= x)
{
tt–;
}
if(tt)
{
printf(“%d “,stk[tt]);
}
else
{
printf(“-1 “);
}
stk[++tt] = x;
}
return 0;
}