#abc372d. D - Buildings

D - Buildings

Score : 400400 points

问题陈述

NN 座建筑物,按照顺序排列为建筑物 11,建筑物 22\ldots,建筑物 NN。建筑物 ii (1iN)(1 \leq i \leq N) 的高度为 HiH_i

对于每个 i=1,2,,Ni = 1, 2, \ldots, N,找出满足以下条件的整数 jj (i<jN)(i < j \leq N) 的数量:

  • 在建筑物 ii 和建筑物 jj 之间没有比建筑物 jj 更高的建筑物。

以上为大语言模型 kimi 翻译,仅供参考。

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 (1iN)(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<jN)(i < j \leq N) satisfying the following condition:

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

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 1HiN1 \leq H_i \leq N
  • HiHj (ij) H_i\neq H_j\ (i\neq j)
  • All input values are integers.

Input

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

NN

H1H_1 H2H_2 \ldots HNH_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.

Sample Input 1

5
2 1 4 3 5

Sample Output 1

3 2 2 1 0

For i=1i=1, the integers jj satisfying the condition are 22, 33, and 55: there are three. (Between Buildings 11 and 44, there is a building taller than Building 44, which is Building 33, so j=4j=4 does not satisfy the condition.) Therefore, the first number in the output is 33.

Sample Input 2

4
1 2 3 4

Sample Output 2

3 2 1 0

Sample Input 3

10
1 9 6 5 2 7 10 4 8 3

Sample Output 3

2 3 3 3 2 1 2 1 1 0