Greatest element on the right

Replace every element with the greatest element to its right, and the last element with -1. Print the new array.

Reported in: Cognizant GenC (GenC Next) (memory-based)

Input

First line: N. Second line: N integers.

Output

The new array, space-separated.

Constraints

1 ≤ N ≤ 10^5.

Example 1

Input:
6
16 17 4 3 5 2

Output:
17 5 5 5 2 -1

Example 2

Input:
1
9

Output:
-1

Hint: Walk from the right end, carrying the maximum seen so far.

All coding practice