Question
Next Taller Tower

A city has N towers standing in a straight line.

The height of the i-th tower is H_i.

For every tower, you need to find the nearest tower on its right side that is strictly taller than it.

If there is no taller tower on the right side, print 0 for that tower.

Input

The first line contains an integer KaTeX can only parse string typed expression — the number of towers.

The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression — the heights of the towers.

Output

Print KaTeX can only parse string typed expression integers, where the KaTeX can only parse string typed expression-th integer is the position of the nearest tower to the right of tower KaTeX can only parse string typed expression that has height strictly greater than KaTeX can only parse string typed expression.

If no such tower exists, print KaTeX can only parse string typed expression for that position.

Example
Example 1:
Input
6

3 1 4 2 5 2
Output
3 3 5 5 0 0
Explanation

For tower KaTeX can only parse string typed expression, the nearest taller tower on the right is tower KaTeX can only parse string typed expression.

For tower KaTeX can only parse string typed expression, the nearest taller tower on the right is tower KaTeX can only parse string typed expression.

For tower KaTeX can only parse string typed expression, the nearest taller tower on the right is tower KaTeX can only parse string typed expression.

For tower KaTeX can only parse string typed expression, the nearest taller tower on the right is tower KaTeX can only parse string typed expression.

For towers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression, there is no taller tower on the right.

Example 2:
Input
5

5 4 3 2 1
Output
0 0 0 0 0
Explanation

No tower has a strictly taller tower on its right side.

Example 3:
Input
5

1 2 3 4 5
Output
2 3 4 5 0
Explanation

For every tower except the last one, the next tower itself is taller.

Online