Question
The Stock Ticker's Next Surge

A stock market monitor records N consecutive price readings for a stock, A_1, A_2, ..., A_N, in chronological order.

For each reading, find the value of the next later reading that is strictly greater than it (the first one that appears after it in the sequence). If no such later reading exists, the answer for that position is -1.

Input

The first line contains a single integer KaTeX can only parse string typed expression — the number of readings. If KaTeX can only parse string typed expression, there are no readings.

The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression.

Output

Print KaTeX can only parse string typed expression integers separated by spaces — for each reading, the next strictly greater reading that appears later, or KaTeX can only parse string typed expression if none exists.

Example
Example 1:
Input
8

73 74 75 71 69 72 76 73
Output
74 75 76 72 72 76 -1 -1
Explanation
For the reading KaTeX can only parse string typed expression at position 1, the next greater reading is KaTeX can only parse string typed expression right after it. For KaTeX can only parse string typed expression at position 4, the next greater reading is KaTeX can only parse string typed expression (skipping over the smaller KaTeX can only parse string typed expression). The last two readings (KaTeX can only parse string typed expression and KaTeX can only parse string typed expression) have nothing greater after them, so both are KaTeX can only parse string typed expression.

Example 2:
Input
5

5 4 3 2 1
Output
-1 -1 -1 -1 -1
Explanation
The readings are strictly decreasing, so no reading ever has a greater one after it.

Example 3:
Input
5

1 2 3 4 5
Output
2 3 4 5 -1
Explanation
The readings are strictly increasing, so every reading except the last one has its immediate successor as the next greater value.

Online