Problem: Tired of boring dates, Leha and Noora decided to play a game.

Leha found a tree with n vertices numbered from 1 to n. We remind you that tree is an undirected graph without cycles. Each vertex v of a tree has a number av written on it. Quite by accident it turned out that all values written on vertices are distinct and are natural numbers between 1 and n.

The game goes in the following way. Noora chooses some vertex u of a tree uniformly at random and passes a move to Leha. Leha, in his turn, chooses (also uniformly at random) some vertex v from remaining vertices of a tree (v ≠ u). As you could guess there are n(n - 1) variants of choosing vertices by players. After that players calculate the value of a function f(u, v) = φ(au·av) · d(u, v) of the chosen vertices where φ(x) is Euler's totient function and d(x, y) is the shortest distance between vertices x and y in a tree.

Soon the game became boring for Noora, so Leha decided to defuse the situation and calculate expected value of function f over all variants of choosing vertices u and v, hoping of at least somehow surprise the girl.

Leha asks for your help in calculating this expected value. Let this value be representable in the form of an irreducible fraction <image>. To further surprise Noora, he wants to name her the value <image>. 

Help Leha!

Input

The first line of input contains one integer number n (2 ≤ n ≤ 2·105) — number of vertices in a tree.

The second line contains n different numbers a1, a2, ..., an (1 ≤ ai ≤ n) separated by spaces, denoting the values written on a tree vertices.

Each of the next n - 1 lines contains two integer numbers x and y (1 ≤ x, y ≤ n), describing the next edge of a tree. It is guaranteed that this set of edges describes a tree.

Output

In a single line print a number equal to P·Q - 1 modulo 109 + 7.

Examples

Input

3
1 2 3
1 2
2 3


Output

333333338


Input

5
5 4 3 1 2
3 5
1 2
4 3
2 5


Output

8

Note

Euler's totient function φ(n) is the number of such i that 1 ≤ i ≤ n,and gcd(i, n) = 1, where gcd(x, y) is the greatest common divisor of numbers x and y.

There are 6 variants of choosing vertices by Leha and Noora in the first testcase:

  * u = 1, v = 2, f(1, 2) = φ(a1·a2)·d(1, 2) = φ(1·2)·1 = φ(2) = 1
  * u = 2, v = 1, f(2, 1) = f(1, 2) = 1
  * u = 1, v = 3, f(1, 3) = φ(a1·a3)·d(1, 3) = φ(1·3)·2 = 2φ(3) = 4
  * u = 3, v = 1, f(3, 1) = f(1, 3) = 4
  * u = 2, v = 3, f(2, 3) = φ(a2·a3)·d(2, 3) = φ(2·3)·1 = φ(6) = 2
  * u = 3, v = 2, f(3, 2) = f(2, 3) = 2



Expected value equals to <image>. The value Leha wants to name Noora is 7·3 - 1 = 7·333333336 = 333333338 <image>.

In the second testcase expected value equals to <image>, so Leha will have to surprise Hoora by number 8·1 - 1 = 8 <image>.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 400010, mod = 1e9 + 7;
int n, a[maxn / 2], head[maxn], to[maxn], nextt[maxn], tot = 1;
int deep[maxn / 2], pos[maxn / 2], dfs_clock, pos2[maxn / 2], dfs_clock2,
    q[maxn * 3], cnt, id[maxn], ST[maxn * 3][21];
int mu[maxn / 2], phi[maxn / 2], prime[maxn / 2], Vis[maxn / 2], Tot, ans,
    f[maxn / 2], S[maxn], top, S2[maxn], top2, sizee[maxn], res, vis[maxn],
    Time;
vector<int> V[maxn / 2];
int qpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = 1LL * res * a % mod;
    a = 1LL * a * a % mod;
    b >>= 1;
  }
  return res;
}
void add(int x, int y) {
  if (x == y) return;
  to[tot] = y;
  nextt[tot] = head[x];
  head[x] = tot++;
}
void init() {
  mu[1] = 1;
  phi[1] = 1;
  int limit = 200000;
  for (int i = 2; i <= limit; i++) {
    if (!Vis[i]) {
      prime[++Tot] = i;
      phi[i] = i - 1;
      mu[i] = -1;
    }
    for (int j = 1; j <= Tot; j++) {
      int t = prime[j] * i;
      if (t > limit) break;
      Vis[t] = 1;
      if (i % prime[j] == 0) {
        phi[t] = phi[i] * prime[j];
        mu[t] = 0;
        break;
      }
      phi[t] = phi[i] * (prime[j] - 1);
      mu[t] = -mu[i];
    }
  }
}
void init_ST() {
  for (int i = 1; i <= cnt; i++) ST[i][0] = q[i];
  for (int j = 1; j <= 20; j++)
    for (int i = 1; i + (1 << j) - 1 <= cnt; i++) {
      if (deep[ST[i][j - 1]] < deep[ST[i + (1 << (j - 1))][j - 1]])
        ST[i][j] = ST[i][j - 1];
      else
        ST[i][j] = ST[i + (1 << (j - 1))][j - 1];
    }
}
int query_ST(int l, int r) {
  if (l > r) swap(l, r);
  int k = (int)(log(r - l + 1) / log(2.0));
  if (deep[ST[l][k]] < deep[ST[r - (1 << k) + 1][k]]) return ST[l][k];
  return ST[r - (1 << k) + 1][k];
}
void dfs(int u, int faa) {
  deep[u] = deep[faa] + 1;
  pos[u] = ++dfs_clock;
  id[dfs_clock] = u;
  q[++cnt] = u;
  pos2[u] = cnt;
  for (int i = head[u]; i; i = nextt[i]) {
    int v = to[i];
    if (v == faa) continue;
    dfs(v, u);
    q[++cnt] = u;
  }
}
void dp(int u, int faa) {
  if (vis[u] == Time)
    sizee[u] = phi[a[u]];
  else
    sizee[u] = 0;
  int temp = 0;
  for (int i = head[u]; i; i = nextt[i]) {
    int v = to[i];
    if (v == faa) continue;
    dp(v, u);
    temp += 1LL * sizee[u] * sizee[v] % mod;
    temp %= mod;
    sizee[u] += sizee[v];
    sizee[u] %= mod;
  }
  if (vis[u] == Time)
    temp = (1LL * temp * 2 % mod + 1LL * phi[a[u]] * phi[a[u]] % mod) % mod;
  else
    temp = 1LL * temp * 2 % mod;
  res = (res - 1LL * temp * deep[u] % mod * 2 % mod + mod) % mod;
  head[u] = 0;
}
int solve(int x) {
  ++Time;
  for (int i = 0; i < V[x].size(); i++) vis[V[x][i]] = Time;
  tot = 1;
  top = top2 = 0;
  S[++top] = 1;
  for (int i = 0; i < V[x].size(); i++) {
    int LCA = query_ST(pos2[V[x][i]], pos2[S[top]]);
    while (1) {
      if (deep[S[top - 1]] <= deep[LCA]) {
        add(LCA, S[top]);
        --top;
        if (S[top] != LCA) {
          S[++top] = LCA;
          S2[++top2] = LCA;
        }
        break;
      }
      --top;
      add(S[top], S[top + 1]);
    }
    if (V[x][i] != S[top]) {
      S[++top] = V[x][i];
      S2[++top2] = V[x][i];
    }
  }
  while (top > 1) {
    add(S[top - 1], S[top]);
    top--;
  }
  res = 0;
  int sum = 0;
  for (int i = 0; i < V[x].size(); i++) (sum += phi[a[V[x][i]]]) %= mod;
  for (int i = 0; i < V[x].size(); i++)
    res = (res +
           1LL * 2 * sum % mod * deep[V[x][i]] % mod * phi[a[V[x][i]]] % mod +
           mod) %
          mod;
  dp(1, 0);
  for (int i = 1; i <= top2; i++) sizee[S2[i]] = 0;
  return res;
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  init_ST();
  for (int i = 1; i <= n; i++) {
    int x = id[i];
    int temp = a[x];
    for (int j = 1; j * j <= temp; j++)
      if (temp % j == 0) {
        V[j].push_back(x);
        if (j * j != temp) V[temp / j].push_back(x);
      }
  }
  memset(head, 0, sizeof(head));
  tot = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = solve(i);
  }
  for (int i = 1; i <= n; i++) {
    int temp = 0;
    for (int j = 1; j * i <= n; j++)
      temp = (temp + 1LL * mu[j] * f[i * j] % mod + mod) % mod;
    temp = 1LL * temp * i % mod * qpow(phi[i], mod - 2) % mod;
    ans = (ans + temp) % mod;
  }
  ans = 1LL * ans * qpow(n, mod - 2) % mod * qpow(n - 1, mod - 2) % mod;
  ans = (ans + mod) % mod;
  printf("%d\n", ans);
  return 0;
}