include[HTML_REMOVED]
using namespace std;
const int N=1e5+9;
int n;
int stk[N],tt;
int main(void){
cin>>n;
for(int i = 0;i < n ;i )
{
int x;
cin>>x;
while(tt && stk[tt]>=x) tt–;
if(tt) cout<<skt[tt]<<” “;
else cout<<-1<<” “;
stk[tt] = x;
}
return 0;
}