#000210

Cuskija

Rearrange the given array of integers so that the sum of two adjacent elements is never divisible by three.


Input The first line contains an integer N (1 ≤ N ≤ 10 000), the number of elements in the array. The second line contains the elements of the array separated by single spaces. The elements will be positive integers less than 1 000 000.

Output If any valid rearrangement exists, output it on a single line. Otherwise, output "impossible".

Input:
3
1 2 3

Output:
2 3 1

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.