from collections import deque
import sys

if __name__ == "__main__" :
    N = int(sys.stdin.readline().rstrip())
    towers = list(map(int, sys.stdin.readline().rstrip().split()))
    
    answer = [0 for _ in range(N)]

    stack = deque()

    for i in range(N - 1, -1, -1) :
        if not stack :
            stack.append((towers[i], i))
        else :
            while True :
                if stack :
                    if towers[i] >= stack[-1][0] :
                        answer[stack[-1][1]] = i + 1
                        stack.pop()
                    else :
                        break
                else :
                    break
            stack.append((towers[i], i))

    answer = list(map(str, answer))
    print(' '.join(answer))
ffbf3610f5ce237a9247491a4a67d50ffeec6e39
<mask token>

<mask token>
if __name__ == '__main__':
    N = int(sys.stdin.readline().rstrip())
    towers = list(map(int, sys.stdin.readline().rstrip().split()))
    answer = [(0) for _ in range(N)]
    stack = deque()
    for i in range(N - 1, -1, -1):
        if not stack:
            stack.append((towers[i], i))
        else:
            while True:
                if stack:
                    if towers[i] >= stack[-1][0]:
                        answer[stack[-1][1]] = i + 1
                        stack.pop()
                    else:
                        break
                else:
                    break
            stack.append((towers[i], i))
    answer = list(map(str, answer))
    print(' '.join(answer))

from collections import deque
import sys
if __name__ == '__main__':
    N = int(sys.stdin.readline().rstrip())
    towers = list(map(int, sys.stdin.readline().rstrip().split()))
    answer = [(0) for _ in range(N)]
    stack = deque()
    for i in range(N - 1, -1, -1):
        if not stack:
            stack.append((towers[i], i))
        else:
            while True:
                if stack:
                    if towers[i] >= stack[-1][0]:
                        answer[stack[-1][1]] = i + 1
                        stack.pop()
                    else:
                        break
                else:
                    break
            stack.append((towers[i], i))
    answer = list(map(str, answer))
    print(' '.join(answer))

from collections import deque
import sys

if __name__ == "__main__" :
    N = int(sys.stdin.readline().rstrip())
    towers = list(map(int, sys.stdin.readline().rstrip().split()))
    
    answer = [0 for _ in range(N)]

    stack = deque()

    for i in range(N - 1, -1, -1) :
        if not stack :
            stack.append((towers[i], i))
        else :
            while True :
                if stack :
                    if towers[i] >= stack[-1][0] :
                        answer[stack[-1][1]] = i + 1
                        stack.pop()
                    else :
                        break
                else :
                    break
            stack.append((towers[i], i))

    answer = list(map(str, answer))
    print(' '.join(answer))