Page not loading? Try clicking here.
Placeholder

#1328

Building 1s 32MB

Problems

There are N buildings. 

The buildings are numbered from 1 to N.

The buildings are located on the X-axis, and building i is located at coordinate i. Each building has a height of H_i.

If i < j and H_i < H_j, building j can be seen from building i

Write a program to find the nearest visible building to the right of each building.


Input

The first line of input contains N (1≤N≤100,000).

From the next line, H_i (1≤H_i≤1,000,000) are given one per line in order.


Output

Output will be on a total of N lines, and on the i-th line, output the number of the nearest building visible from building i

If there are no visible buildings, output 0.


Example

6 

3
2
6
1
1
2
3 

3
0
6
6
0


You must sign in to write code.