Weird sort
Having a sequence of n integers a[1]
, a[2]
, …, a[n]
, you need to order them in a way when no two consecutive integers have consecutive values. In other words the condition a[i]
+ 1 ≠ a[i+1]
(0 < i < n) should be satisfied for the final sequence.
If more than one sequence satisfying this condition exists, lexicographically minimal one should be found.
Input
Consists of several data sets. In the first line of each set the sequence length n (1 ≤ n ≤ 50000) is given. The second line contains n integers a[1]
, a[2]
, …, a[n]
, separated by single spaces. Each integer does not exceed 10^9
in its absolute value. The value n = 0 indicates the end of the input.
Output
For each data set you need to print result sequence in separate line. Integers in the sequence must be separated by single spaces. Print "No solution" (without quotes) if requested sequence does not exist.