#include<iostream>
#include<stack>
using namespace std;
stack<int>s; int a[100010], ans[100010];
int main()
{
int n; cin >> n;
for (int i = 0; i < n; i++)cin >> a[i];
for (int i = n - 1; i >= 0; i--)
{
while (!s.empty() && a[s.top()] <= a[i])s.pop();
if (!s.empty())ans[i] = s.top();
else ans[i] = 0;
s.push(i);
}
for (int i = 0; i < n; i++)
{
if (ans[i] != 0)cout << ans[i] + 1 << " ";
else cout << 0<<" ";
}
return 0;
}