Median

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

An integer sequence a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n is good if m_1m_2m_nm\_1 \leq m\_2 \leq \dots \leq m\_n where m_im\_i is the median of a_1,a_2,,a_ia\_1, a\_2, \ldots, a\_i.

Given a sequence p_1,p_2,,p_np\_1, p\_2, \dots, p\_n, find its permutation which is good. If the result is not unique, find the lexicographically largest one.

For a sequence a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n, the median is the n/2\lceil n/2 \rceil-th largest element if nn is odd, or the average of the n/2n/2-th largest and the (n/2+1)(n/2+1)-th largest elements if nn is even.

입력

The first line contains an integer nn (1n1051 \leq n \leq 10^5).

The second line contains nn integers p_1,p_2,,p_np\_1, p\_2, \ldots, p\_n (1p_i1091 \leq p\_i \leq 10^9).

출력

On the first line, print nn integers which denote the lexicographically largest good permutation of the input sequence.