#STK0000077. Tháp thu tín hiệu (Tower)

Tháp thu tín hiệu (Tower)

Tower

Source: Baekjoon Online Judge

Version: Phuoc Hung OJ Extended

Problem Statement

There are NN towers of distinct heights arranged from left to right and numbered 11 through NN. Every tower emits a horizontal laser to the left. The laser from tower ii is received by the first tower to its left whose height is greater than HiH_i; shorter towers do not block it. If no such tower exists, the answer is 00. Determine the receiving tower for every transmitter.

Input

The first line contains NN. The second line contains the NN tower heights from left to right. All heights are distinct.

Output

Print NN integers. The ii-th integer is the index of the tower that receives the laser from tower ii, or 00 if no tower receives it.

Subtasks

  • Subtask 1 (30 points): N≤2000N\le2000; all other conditions are unchanged.
  • Subtask 2 (70 points): 1≤N≤5⋅1051\le N\le5\cdot10^5, 1≤Hi≤1081\le H_i\le10^8, các HiH_i đôi một khác nhau.

Examples

Input

5
6 9 5 7 4

Output

0 0 2 2 4

Explanation

The tower heights are 6,9,5,7,46,9,5,7,4.

  • Tower 11 has no tower to its left, so its answer is 00.
  • Tower 22 has height 99. Its laser passes tower 11 of height 6<96<9, and there is no taller tower farther left, so its answer is 00.
  • Tower 33 has height 55 and immediately meets tower 22 of height 9>59>5, so its answer is 22.
  • Tower 44 has height 77. Its laser passes tower 33 of height 55 and then reaches tower 22 of height 9>79>7, so its answer is 22.
  • Tower 55 has height 44 and immediately reaches tower 44 of height 7>47>4, so its answer is 44.

Therefore the output is 0 0 2 2 4.