Lexicographically smallest cyclic shift#1783

Lexicographically smallest cyclic shift

1 second
128 megabytes
Very easy

A permutation of length is a sequence of pairwise distinct positive integers p_1, p_2, \ldots, p_n, where 1 \le p_i \le n for each . We say that the permutation q_1, q_2, \ldots, q_n is lexicographically less than the permutation p_1, p_2, \ldots, p_n if there exists such that q_i < p_i and for all j < i we have p_j = q_j.

A cyclic shift by of the permutation p_1, p_2, \ldots, p_n is the sequence p_{k+1}, p_{k+2}, \ldots, p_n, p_1, \ldots, p_k. Note that any cyclic shift of a permutation is also a permutation.

Find the lexicographically smallest cyclic shift of the given permutation.

Input

The first line contains an integer (1 \le n \le 10^5), the length of the permutation. The second line contains p_1, p_2, \ldots, p_n.

Output

Output the lexicographically smallest cyclic shift of the given permutation, in the same format as the second line of the input.

Examples

Example 1

Loading
Loading