Ring of Racks
A data center has n server racks arranged in a ring, numbered 0 to n-1 clockwise, with rack n-1 adjacent to rack 0. Each rack reports a current load a_i.
To shed load, every rack wants to forward its work to the nearest rack clockwise (increasing index, wrapping around after n-1 back to 0) whose load is strictly greater than its own. A rack may need to look all the way around the ring, possibly passing other racks several times over, but it never forwards to itself.
For each rack, find the index of the first rack clockwise with a strictly greater load, or -1 if no rack in the ring has a strictly greater load.
Input
The first line contains n (1 ≤ n ≤ 2·10^5).
The second line contains n integers a_0, a_1, …, a_{n-1} (1 ≤ a_i ≤ 10^9), the loads of the racks in clockwise order.
Output
Print n integers separated by spaces: for each rack i, the index of the first rack strictly clockwise from it with a strictly greater load, or -1 if none exists.
Notes
Many loads can be equal; equal loads never satisfy another rack's request, so ties keep looking further clockwise.