871. Football Team on a Circular Path

0

Medium

The football team was standing on a circular path and each player is having a jersey number. Players can have same jersey number. The Team played a game where each player returns the next greater jersey number. If there is no next greater Jersey number exist then it will return -1.

Input Format

First line contains number of players N. Second line contains jersey numbers.

Output Format

An array representing 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