#include<iostream>
#include<vector>
#include<stack>
using namespace std;
int main(void) {
int n; cin >> n;
vector<int>arr(n);//找出每个数左边第一个比它小的数
stack<int>stk;
for (int i = 0; i < n; ++i) {
int tmp; cin >> tmp;
while (!stk.empty() && tmp <= stk.top())stk.pop();
arr[i] = stk.empty() ? -1 : stk.top();
stk.push(tmp);
}
for (auto vi : arr)cout << vi << " ";
cout << endl;
return 0;
}