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:
Output:
3
1 2 3Output:
2 3 1Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.