Hide

Problem B
Aldursröðun

Languages en is
/problems/aldursrodun/file/statement/en/img-0001.jpg
Birthday by Jon Tyson, Unsplash
It is well known that there is no job more important than being a mother. You, a proud mother, want to snap a photo of your children to share on social media. But order is important to you. You want the age of adjacent children to have a common divisor greater than one. A common divisor of two numbers is any number that divides both numbers without remainder.

Input

The first line of the input contains an integer $3 \leq n \leq 8$. The next line of the input contains $n$ integers, $1 \leq c_ i \leq 10^9$. The integer $c_ i$ describes the age of your $i$-th child.

Output

The first line of the output should contain the ages of your children after they have been rearranged to fit the criterion above. If there are multiple valid rearrangements, print any of them. If no such rearrangement exists, print ,,Neibb”.

Scoring

Group

Points

Constraints

1

50

$n = 3$ and $c_ i \leq 100$

2

40

$c_ i \leq 100$

2

10

No further constraints

Sample Input 1 Sample Output 1
3
2 3 6
2 6 3 
Sample Input 2 Sample Output 2
7
5 10 7 15 14 3 2
7 14 2 10 5 15 3 
Sample Input 3 Sample Output 3
4
2 5 7 10
Neibb

Please log in to submit a solution to this problem

Log in