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, for all i, where 0<i<N, condition a1+1 ≠ a1+1 should be satisfied for the final sequence.
Sample Input
- 1 2
- 1 2 3 4 5 6
- 1 1 2 2 3 3
Sample Output
- 2 1
- 1 3 2 4 6 5
- 1 1 3 3 2 2