Replacement#4892

Replacement

1 segundo
128 megabytes
Media

Given a sequence of positive integers. You must replace each element with the next nearest one (with a larger index) that is strictly larger than its value. If there is no larger element, replace this element with zero.

Entrada

First line contains the number of elements (1 \le n \le 10^5). Second line contains positive integers a_i (a_i \le 10^9) - the values of sequence elements.

Salida

Print the desired sequence, separating the neighboring elements with a single space.

Ejemplos

Ejemplo 1

Loading
Loading

Ejemplo 2

Loading
Loading