478. Football Team on a Circular Path

0

Medium

A football team is positioned on a circular path, with each player assigned a jersey number. It is possible for multiple players to have the same jersey number. The team plays a game where each player must find the next player with a greater jersey number. If there is no player with a greater jersey number, the player will return -1.

Input Format

The first line of input contains the number of players, N. The second line contains the jersey numbers of the players.

Output Format

An array representing the next greater elements

Example

Input

3 1 2 1

Output

2 -1 2

Constraints

- 1 <= nums.length <= 10^4 - 10^9 <= nums[i] <= 10^9
Loading...

View Submissions

Console