시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB47262356.098%

문제

Given is a sequence of N integers a1, a2, ..., an. For any element ak (k = 1, 2, ..., n) we find the first larger than ak element, which is placed to the right of ak (if such exists). Denote it by ak1. Then do the same with ak1 and denote the found element by ak2, and so on until we run out of the given sequence. Thus formed subsequence ak1, ak2, ..., we call chain beginning at index k.

Write program chain that outputs for any index k the length of the corresponding chain that begins at index k.

입력

On the first line of the standard input, the value of N is written. On the second line, the elements of the given sequence are written, separated by spaces.

출력

On a line in the standard output, your program has to write the sequence of chain’s lengths, corresponding to the element of the input data. Each two consecutive numbers in the output must be separated by a single space.

제한

  • 0 < N < 500 000
  • 0 < ai < 1 000 000, for each i = 1, ..., N.

예제 입력 1

11
3 2 4 2 11 2 7 5 8 10 6

예제 출력 1

2 2 1 1 0 3 2 2 1 0 0