#STK0000081. Các tòa nhà (Buildings)

Các tòa nhà (Buildings)

Buildings

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are NN buildings numbered 11 through NN, where building ii has height HiH_i. All heights are distinct. For every ii, count the indices j>ij>i such that no building strictly between ii and jj is taller than building jj.

Input

The first line contains NN. The second line contains NN integers H1,H2,…,HNH_1,H_2,\ldots,H_N.

Output

Print NN integers; the ii-th integer is the number of buildings jj satisfying the condition for building ii.

Subtasks

  • Subtask 1 (30 points): N≤2000N\le2000; all other conditions are unchanged.
  • Subtask 2 (70 points): 1≤N≤2⋅1051\le N\le2\cdot10^5, 1≤Hi≤N1\le H_i\le N, các HiH_i đôi một khác nhau.

Examples

Input

5
2 1 4 3 5

Output

3 2 2 1 0

Explanation

The heights are 2,1,4,3,52,1,4,3,5.

  • For i=1i=1, the valid indices are j=2,3,5j=2,3,5. Index j=4j=4 is invalid because building 33 of height 44 lies between them and is taller than building 44 of height 33. Hence c1=3c_1=3.
  • For i=2i=2, j=3j=3 and j=5j=5 are valid, while j=4j=4 is blocked by the taller building 33. Thus c2=2c_2=2.
  • For i=3i=3, both j=4j=4 and j=5j=5 satisfy the condition, so c3=2c_3=2.
  • For i=4i=4, only j=5j=5 is available and valid, so c4=1c_4=1.
  • For i=5i=5, there is no building to the right, so c5=0c_5=0.

Therefore the program prints 3 2 2 1 0.