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>
const int Mod = 1000000007;
const int MN = 200005, MP = 17995;
inline int qPow(int b, int e) {
  int a = 1;
  for (; e; e >>= 1, b = (long long)b * b % Mod)
    if (e & 1) a = (long long)a * b % Mod;
  return a;
}
bool ip[MN];
int p[MP], pc;
int Inv[MN], phi[MN], f[MN];
std::vector<int> F[MN];
inline void Init(const int &N) {
  Inv[0] = 1;
  for (int i = 1; i <= N; ++i) Inv[i] = (long long)Inv[i - 1] * i % Mod;
  int iFac = qPow(Inv[N], Mod - 2);
  for (int i = N; i >= 1; --i)
    Inv[i] = (long long)iFac * Inv[i - 1] % Mod,
    iFac = (long long)iFac * i % Mod;
  phi[1] = f[1] = 1;
  for (int i = 2; i <= N; ++i) {
    if (!ip[i]) p[++pc] = i, phi[i] = i - 1, f[i] = Inv[i - 1];
    for (int j = 1; j <= pc; ++j) {
      const int &k = p[j] * i;
      if (k > N) break;
      ip[k] = 1;
      if (i % p[j])
        phi[k] = phi[i] * (p[j] - 1), f[k] = (long long)f[i] * f[p[j]] % Mod;
      else {
        phi[k] = phi[i] * p[j];
        break;
      }
    }
  }
  for (int i = 1; i <= N; ++i)
    if (f[i])
      for (int j = i; j <= N; j += i) F[j].push_back(i);
}
int N, A[MN], Ans;
std::vector<int> G[MN];
int dep[MN], dfn[MN], idf[MN], dfc;
int ieu[MN * 2], leu[MN], reu[MN], euc;
void DFS(const int &u, const int &fz) {
  dep[u] = dep[fz] + 1;
  idf[dfn[u] = ++dfc] = u;
  ieu[leu[u] = ++euc] = u;
  for (auto v : G[u])
    if (v != fz) DFS(v, u), ieu[++euc] = u;
  reu[u] = euc;
}
inline int ckdep(const int &i, const int &j) { return dep[i] < dep[j] ? i : j; }
int lg[MN * 2], ST[19][MN * 2];
void _ST() {
  lg[0] = -1;
  for (int i = 1; i <= euc; ++i) {
    lg[i] = lg[i >> 1] + 1;
    ST[0][i] = ieu[i];
  }
  for (int j = 0; j < lg[euc]; ++j)
    for (int i = 2 << j; i <= euc; ++i)
      ST[j + 1][i] = ckdep(ST[j][i - (1 << j)], ST[j][i]);
}
inline int rmq(const int &l, const int &r) {
  const int &g = lg[r - l + 1];
  return ckdep(ST[g][l + (1 << g) - 1], ST[g][r]);
}
inline int lca(const int &u, const int &v) {
  if (reu[u] < leu[v]) return rmq(reu[u], leu[v]);
  if (reu[v] < leu[u]) return rmq(reu[v], leu[u]);
  return ckdep(u, v);
}
std::vector<int> V[MN];
int stk[MN], tp, st[MN], t;
std::vector<int> T[MN];
int val[MN];
inline void AddP(const int &x, const int &y) {
  if (y) T[x].push_back(y), val[y] = dep[y] - dep[x];
}
int it[MN], sphi[MN], Sum;
inline void DP(const int &u) {
  sphi[u] = it[u] ? phi[A[u]] : 0;
  for (auto v : T[u]) {
    DP(v);
    sphi[u] += sphi[v];
    if (sphi[u] >= Mod) sphi[u] -= Mod;
  }
  Sum = (Sum - (long long)sphi[u] * sphi[u] % Mod * val[u]) % Mod;
}
void vtree() {
  for (int id = 1; id <= N; ++id) {
    int u = idf[id], k = A[u];
    for (auto i : F[k]) V[i].push_back(u);
  }
  for (int i = 1; i <= N; ++i) {
    if (!f[i]) continue;
    int sz = V[i].size(), x;
    int S1 = 0, S2 = 0;
    for (int j = 0; j < sz; ++j) {
      int u = V[i][j];
      it[u] = 1;
      st[++t] = u;
      S1 += phi[A[u]];
      if (S1 >= Mod) S1 -= Mod;
      S2 = (S2 + (long long)phi[A[u]] * dep[u]) % Mod;
      if (tp) {
        const int &l = lca(stk[tp], u), &dl = dep[l];
        for (x = 0; tp && dep[stk[tp]] > dl; x = stk[tp--]) AddP(stk[tp], x);
        if (stk[tp] != l) stk[++tp] = l, st[++t] = l;
        AddP(stk[tp], x);
        stk[++tp] = u;
      } else
        stk[++tp] = u;
    }
    for (x = 0; tp; x = stk[tp--]) AddP(stk[tp], x);
    val[x] = dep[x];
    Sum = (long long)S1 * S2 % Mod;
    DP(x);
    Ans = (Ans + (long long)f[i] * (Sum + Mod)) % Mod;
    while (t) it[st[t]] = 0, T[st[t--]].clear();
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  Init(N);
  for (int i = 1, x, y; i < N; ++i)
    scanf("%d%d", &x, &y), G[x].push_back(y), G[y].push_back(x);
  DFS(1, 0);
  _ST();
  vtree();
  printf("%lld\n", (long long)Ans *
                       qPow((long long)N * (N - 1) / 2 % Mod, Mod - 2) % Mod);
  return 0;
}