Next Greater Element


You are given an array of integers.

For each position ii, find the first element to the right of ii that is strictly greater than aia_i. If no such element exists, output -1 for that position.

Input

The first line contains an integer nn, the size of the array.

The second line contains nn integers: a1,a2,…,ana_1, a_2, \ldots, a_n.

Output

Print nn integers, where the ii-th integer is the next greater element to the right of aia_i, or -1 if none exists.

Constraints

  • 1≤n≤2⋅1051 \le n \le 2 \cdot 10^5
  • −109≤ai≤109-10^9 \le a_i \le 10^9

Example 1

Input 1
5
4 5 2 10 8
Output 1
5 10 10 -1 -1

Example 2

Input 2
4
13 7 6 12
Output 2
-1 12 12 -1

Example 3

Input 3
4
3 3 3 3
Output 3
-1 -1 -1 -1

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.