A gauge dial has n readings arranged in a circle. Starting from any reading and scanning clockwise (advancing to the next index, wrapping from the last back to the first), find the first reading strictly greater than the starting one. Report that greater value for each reading, or -1 if no other reading in the whole circle is strictly greater.
Because the dial is circular, the search from a reading may wrap past the end of the list back to the beginning; it stops before returning to the starting reading itself.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the readings in clockwise order.
Output format
n space-separated integers on one line: for each reading (in the given order), the next strictly-higher reading found scanning clockwise, or -1.
Constraints
- 1 <= n <= 100000
- 1 <= reading <= 1000000000