A stock market monitor records
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
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.
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.
Input
8
73 74 75 71 69 72 76 73Output74 75 76 72 72 76 -1 -1ExplanationFor 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 1Output-1 -1 -1 -1 -1ExplanationThe readings are strictly decreasing, so no reading ever has a greater one after it.
Example 3:
Input
5
1 2 3 4 5Output2 3 4 5 -1ExplanationThe readings are strictly increasing, so every reading except the last one has its immediate successor as the next greater value.