#include<bits/stdc++.h>
using namespace std;
struct stack {
int val,num;
} s[100002];
int size,n,a[100002],b[100002];
int main() {
freopen("lookup.in","r",stdin);
freopen("lookup.out","w",stdout);
cin>>n;
for (int i = 1; i <= n; i++) {
cin>>a[i];
}
for (int i = n-1; i >= 1; i--) {
int j=i+1;
while (a[i]>=a[j]&&a[j]>0) {
j=b[j];
}
b[i]=j;
}
for (int i = 1; i <= n; i++) {
cout<<b[i]<<endl;
}
}