Question
Clockwise Next Peak
You are given
For every position
If no greater value exists after making at most one full trip around the circle, output
Input
The first line contains KaTeX can only parse string typed expression.
The second line contains KaTeX can only parse string typed expression integers.
Output
Print KaTeX can only parse string typed expression integers. The KaTeX can only parse string typed expression-th integer is the clockwise distance to the first strictly greater value, or 0 if none exists.
Example
Input:
5
3 1 2 4 2Output:3 1 1 0 1