#include <bits/stdc++.h>
using namespace std;
int f[1500], f2[1500][1500], b[100000];
int top = 1;
int n, x, m;
struct str {
int num, data;
} a[100000], filo[100000];
void solve() {
cin >> n
for(int i = 1; i <= n; ++i) {
cin >> a[i].data;
a[i].num = i;
for(int j = top; j >= 1; --j) {
if(filo[top].data < a[i].data){
b[filo[top].num] = a[i].num;
--top;
// filo[++top] = a[i];
}
// filo[++top] = a[i];
}
filo[++top] = a[i];
}
for(int i = 1; i <= n; ++i)
cout << b[i] << endl;
}
int main() {
ios::sync_with_stdio(false);
solve();
return 0;
}
TLE #2, #3, #4, #12