from sys import stdin
n = int(stdin.readline())
tower = list(map(int, stdin.readline().split(' ')))
ans = []
stack = []
for i in range(n):
    while stack:
        if stack[-1][1] > tower[i]:
            ans.append(stack[-1][0] + 1)
            break
        stack.pop()
    if not stack:
        ans.append(0)
    stack.append((i, tower[i]))
for i in ans:
    print(i, end=' ')

471fe5514b1a43030d2948fccc0165d6b997e9aa
<mask token>

<mask token>
for i in range(n):
    while stack:
        if stack[-1][1] > tower[i]:
            ans.append(stack[-1][0] + 1)
            break
        stack.pop()
    if not stack:
        ans.append(0)
    stack.append((i, tower[i]))
for i in ans:
    print(i, end=' ')

<mask token>
n = int(stdin.readline())
tower = list(map(int, stdin.readline().split(' ')))
ans = []
stack = []
for i in range(n):
    while stack:
        if stack[-1][1] > tower[i]:
            ans.append(stack[-1][0] + 1)
            break
        stack.pop()
    if not stack:
        ans.append(0)
    stack.append((i, tower[i]))
for i in ans:
    print(i, end=' ')

from sys import stdin
n = int(stdin.readline())
tower = list(map(int, stdin.readline().split(' ')))
ans = []
stack = []
for i in range(n):
    while stack:
        if stack[-1][1] > tower[i]:
            ans.append(stack[-1][0] + 1)
            break
        stack.pop()
    if not stack:
        ans.append(0)
    stack.append((i, tower[i]))
for i in ans:
    print(i, end=' ')
