#STK0000086. Hàng đợi (Queue)

Hàng đợi (Queue)

Queue

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn people in a queue from left to right, where person ii has value aia_i. For every ii, find the farthest position j>ij>i to the right such that aj<aia_j<a_i. If it exists, print the number of people strictly between ii and jj, namely j−i−1j-i-1; otherwise print −1-1.

Input

The first line contains nn. The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print nn integers in position order.

Subtasks

  • Subtask 1 (30 points): n≤2000n\le2000; all other conditions are unchanged.
  • Subtask 2 (70 points): 2≤n≤1052\le n\le10^5, 1≤ai≤1091\le a_i\le10^9.

Examples

Input

6
10 8 5 3 50 45

Output

2 1 0 -1 0 -1

Explanation

The values are 10,8,5,3,50,4510,8,5,3,50,45.

  • Position 11 has value 1010. The farthest smaller value to the right is 33 at position 44. Positions 22 and 33 lie between them, so the answer is 22.
  • Position 22 has value 88. The farthest smaller value is again at position 44; only position 33 lies between them, so the answer is 11.
  • Position 33 has value 55. Position 44 has value 3<53<5, and there is no farther smaller value, so the number of positions between them is 00.
  • Position 44 has value 33. No smaller value exists to its right, so the answer is −1-1.
  • Position 55 has value 5050. Position 66 has value 45<5045<50 and is adjacent, so the answer is 00.
  • Position 66 has nobody to its right, so the answer is −1-1.

Therefore the output is 2 1 0 -1 0 -1.