#include <bits/stdc++.h>
using namespace std;
const int N = 30000005;
int a[N] , n , h[N];
stack<int> s;
int main()
{
scanf("%d" , &n);
for(int i = 1 ; i <= n ; i++) scanf("%d" , &a[i]);
for(int i = n ; i >= 1 ; i--)
{
while(!s.empty() && a[s.top()] < a[i]) s.pop();
if(s.empty()) h[i] = 0;
else h[i] = s.top();
s.push(i);
}
for(int i = 1 ; i <= n ; i++) printf("%d " , h[i]);
return 0;
}