def solution(prices):
    length = len(prices) - 1
    answer = []
    stack = []
    while prices :
        temp = prices.pop()
        count = 1
        while stack and stack[len(stack)-1][0] >= temp :
            _, temp_count = stack.pop()
            count += temp_count
        if stack : answer.append(count)
        else : answer.append(length-len(prices))
        stack.append([temp, count])
    
    answer.reverse()
    return answer