How Many Can You See?
n people stand in a row, numbered 1 to n from left to right, all facing right (toward
increasing index). Person i has height h_i, and all heights are distinct.
Person i can see person j, for j > i, if every person standing strictly between them — at
positions i+1, i+2, …, j-1 — is strictly shorter than both person i and person j. In
particular, person i can always see person i+1: nobody stands between them. A person who is at
least as tall as person i blocks the view of everyone standing beyond, no matter how tall that
further person is.
For every person, print how many people they can see somewhere to their right.
Input
The first line contains an integer n (1 ≤ n ≤ 2·10^5), the number of people.
The second line contains n distinct integers h_1, h_2, …, h_n (1 ≤ h_i ≤ 10^9), the heights from
left to right.
Output
Print n integers separated by spaces: the i-th of them is the number of people that person i
can see to their right.
Notes
In the first example the heights are 10 6 8 5 11 9. Person 1 (height 10) sees person 2 (height 6,
nobody stands between them), person 3 (height 8, since person 2 is shorter than both), and person 5
(height 11, since persons 2, 3 and 4 are all shorter than both 10 and 11). Person 1 cannot see person
4 (height 5): person 3 stands between them with height 8, which is not shorter than person 4. Person
1 also cannot see person 6: person 5 stands between them with height 11, which is taller than person
1 and blocks the view no matter who stands further away. So person 1 can see 3 people in total.
Person 6, last in line, can see 0 people — nobody stands to their right.