ICPC North America Qualifier 2018

#### Start

2018-10-06 08:00 AKDT

## ICPC North America Qualifier 2018

#### End

2018-10-06 13:00 AKDT
The end is near!
Contest is over.
Not yet started.
Contest is starting in -926 days 11:05:25

5:00:00

0:00:00

# Problem FLCM Tree

An LCM tree is a binary tree in which each node has a positive integer value, and either zero or two children. If two nodes $x$ and $y$ are the children of node $z$, then the Least Common Multiple (LCM) of the values of node $x$ and node $y$ must equal the value of node $z$.

You are given $n$ nodes with positive integer values to be arranged into an LCM tree. In how many ways (modulo $10^9 + 7$) can you do that? Two ways are considered different if there are two nodes $x$ and $y$ so that $x$ is a child of $y$ in one way but not in the other way.

The illustration shows one of the two ways for the first sample case. The other way can be obtained by swapping the two nodes with value $4$. Note that swapping the two leaves with values $2$ and $4$ does not give a different way.

## Input

The first line has an odd integer $n$ ($1 \leq n \leq 25$). The second line has $n$ positive integers no larger than $10^9$, giving the values of the nodes.

## Output

Output the number of ways to arrange the given nodes into an LCM tree, modulo $10^9 + 7$.

Sample Input 1 Sample Output 1
7
2 3 4 4 8 12 24

2

Sample Input 2 Sample Output 2
3
7 7 7

3

Sample Input 3 Sample Output 3
5
1 2 3 2 1

0

Sample Input 4 Sample Output 4
13
1 1 1 1 1 1 1 1 1 1 1 1 1

843230316