eolymp
bolt
Try our new interface for solving problems
Problems

Weird sort

Weird sort

Having a sequence of n integers a1, a2, …, an, you need to order them in a way when no two consecutive integers have consecutive values. In other words the condition ai + 1ai+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 (1n50000) is given. The second line contains n integers a1, a2, …, an, separated by single spaces. Each integer does not exceed 109 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.

Time limit 1 second
Memory limit 64 MiB
Input example #1
2
1 2 
0
Output example #1
2 1
Source All-Ukrainian Collegiate Programming Contest Semi-Final 2010