#include<iostream>
#include<stack>
using namespace std;
const int N = 3000010;
int a[N];
int ans[N];
stack<pair<int, int>> stk;
int main()
{
int n; cin >> n;
for (int i = 1; i <= n; i++)
cin>>a[i];
for (int i = 1; i <= n; i++)//1 5 2 3 4
{
while (stk.size() && a[i] > stk.top().first)
{
ans[stk.top().second] = i;
stk.pop();
}
stk.push(make_pair(a[i], i));
}
for (int i = 1; i <= n; i++)
cout << ans[i] << " ";
return 0;
}