h2. Date de intrare
The first line of the input will contain $N$, the number of nodes. The second line will contain $N$ numbers, the $i-th$ number, representing the <tex>value_i</tex>. Each of the next $N - 1$ lines will contain a pair of nodes $(u, v)$, each representing an edge of the tree.
The first line of the input will contain $N$ (1 ≤ $N$ ≤ 100000), the number of nodes. The second line will contain $N$ numbers, the $i-th$ number, representing the <tex>value_i</tex> (1 ≤ <tex>value_i</tex> ≤ 30000). Each of the next $N - 1$ lines will contain a pair of nodes $(u, v)$, each representing an edge of the tree.
h2. Date de ieşire
The output will contain the sum of costs over all pairs of nodes $(u, v)$, such that <tex>gcd(value_u, value_v) > 1</tex>
The output will contain the sum of costs over all pairs of nodes $(u, v)$, such that $gcd(value[u], value[v]) > 1$
h2. Restricţii
* 1 ≤ $N$ ≤ 100000
* 1 ≤ <tex>value_i</tex> ≤ 30000
* For the first subtask (1 ≤ $N$ ≤ 1000)
* For the second subtask, <tex> value_i = value_1 </tex> for $i = 1, 2,...n$
For the first subtask (1 ≤ $N$ ≤ 1000)
For the second subtask, <tex> value[i] = value[1] </tex> for $i = 1, 2,...n$
h2. Exemplu