Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

3209.   Look Up
Time Limit: 2.0 Seconds   Memory Limit: 65536K
Total Runs: 1049   Accepted Runs: 366    Multiple test files



Farmer John's N (1 ≤ N ≤ 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height H_i (1 ≤ H_i ≤ 1,000,000).

Each cow is looking to her left toward those with higher index numbers. We say that cow i 'looks up' to cow j if i < j and H_i < H_j. For each cow i, FJ would like to know the index of the first cow in line looked up to by cow i.

Note: about 50% of the test data will have N ≤ 1,000.

Input

* Line 1: A single integer: N
* Lines 2..N+1: Line i+1 contains the single integer: H_i

Output

* Lines 1..N: Line i contains a single integer representing the smallest index of a cow up to which cow i looks. If no such cow exists, print 0.

Sample Input

6
3
2
6
1
1
2

Sample Output

3
3
0
6
6
0



Source: USACO 2009 March Competition
Submit   List    Runs   Forum   Statistics

Tianjin University Online Judge v1.3.0
Maintance:Fxz. Developer: SuperHacker, G.D.Retop, Fxz