279 传统题

[ABC372D] 楼房视野 (Buildings)

时间限制
2000ms
内存限制
256MiB
登顶 / 尝试
0/ 0
难度
3

[ABC372D] 楼房视野 (Buildings)

Problem Statement

There are NN buildings, Building 11, Building 22, …\ldots, Building NN, arranged in a line in this order. The height of Building ii (1≤i≤N)(1 \leq i \leq N) is HiH_i.

For each i=1,2,…,Ni = 1, 2, \ldots, N, find the number of integers jj (i<j≤N)(i < j \leq N) satisfying the following condition:

  • There is no building taller than Building jj between Buildings ii and jj.

Input

The input is given from Standard Input in the following format:

$N$
$H_1$ $H_2$ $\ldots$ $H_N$

Output

For each i=1,2,…,Ni = 1, 2, \ldots, N, let cic_i be the number of jj satisfying the condition. Print c1,c2,…,cNc_1, c_2, \ldots, c_N in order, separated by spaces.

Example

5
2 1 4 3 5
3 2 2 1 0

Note

  • Constraints:

  • 1≤N≤2×1051 \leq N \leq 2 \times 10^5

  • 1≤Hi≤N1 \leq H_i \leq N

  • Hi≠Hj (i≠j) H_i\neq H_j\ (i\neq j)

  • All input values are integers.

  • Source: ABC372D