#include<bits/stdc++.h>
using namespace std;
const int N=3e6+10;
int ans[N];
struct node{
int v,index;
}a[N];
int n,cnt=0;
inline int read()
{
int x=0,t=1;char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
if(ch=='-'){t=-1;ch=getchar();}
while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getchar();}
return x*t;
}
int main()
{
stack <node> s;
n=read();
for(int i=1;i<=n;i++)
a[i].v=read(),a[i].index=i;
s.push(a[n]);ans[n]=0;
for(int i=n-1;i>=1;i--)//从后往前找
{
if(a[i].v<s.top().v)
{
ans[i]=s.top().index;
s.push(a[i]);
}
else
{
while(!s.empty()&&a[i].v>=s.top().v)
s.pop();
if(s.empty()) ans[i]=0;//说明后面没有比它大的元素
else ans[i]=s.top().index;//栈顶元素的下标即为答案
s.push(a[i]);
}
}
for(int i=1;i<=n;i++)
cout<<ans[i]<<" ";
return 0;
}