#include <iostream>
#include <stack>
#include <vector>
using namespace std;
struct student{
int height;
int idx;
student(){}
student(int h,int i):height(h),idx(i){}
};
int main(){
int n;
while (cin>>n){
vector<student> sV(n);
int h;
stack<student> hS;
vector<int> ans(n,0);
for (int i = 0; i < n; ++i) {
cin>>h;
sV.emplace_back(h,i);
while (!hS.empty() && hS.top().height < h){
student stu = hS.top();
ans[stu.idx] = i;
hS.pop();
}
hS.emplace(h,i);
}
for (int a:ans) {
cout<<a<<" ";
}
cout<<endl;
}
return 0;
}