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;
inline int gi() {
  char c;
  int num = 0, flg = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flg = -1;
  while (c >= '0' && c <= '9') {
    num = num * 10 + c - 48;
    c = getchar();
  }
  return num * flg;
}
const int mod = 1000000007;
int ksm(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % mod;
    y >>= 1;
    x = 1ll * x * x % mod;
  }
  return ret;
}
int prime[200005], tot, mu[200005], phi[200005], inv[200005];
bool vis[200005];
void shai() {
  int i, j, n = 200000;
  inv[0] = inv[1] = phi[1] = mu[1] = 1;
  vis[1] = 1;
  for (i = 2; i <= n; i++) {
    inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
    if (!vis[i]) {
      prime[++tot] = i;
      mu[i] = -1;
      phi[i] = i - 1;
    }
    for (j = 1; j <= tot; j++) {
      int tmp = i * prime[j];
      if (tmp > n) break;
      vis[tmp] = 1;
      if (i % prime[j] == 0) {
        mu[tmp] = 0;
        phi[tmp] = phi[i] * prime[j];
        break;
      }
      mu[tmp] = (mod - mu[i]) % mod;
      phi[tmp] = phi[i] * (prime[j] - 1);
    }
  }
}
int a[200005], fir[200005], to[2 * 200005], nxt[2 * 200005], cd[2 * 200005],
    cnt;
int dep[200005], fa[200005], top[200005], siz[200005], son[200005];
void adde(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  to[++cnt] = b;
  nxt[cnt] = fir[a];
  fir[a] = cnt;
  cd[cnt] = dep[b] - dep[a];
  to[++cnt] = a;
  nxt[cnt] = fir[b];
  fir[b] = cnt;
  cd[cnt] = dep[b] - dep[a];
}
void dfs1(int u) {
  dep[u] = dep[fa[u]] + 1;
  siz[u] = 1;
  for (int v, p = fir[u]; p; p = nxt[p]) {
    if ((v = to[p]) != fa[u]) {
      fa[v] = u;
      dfs1(v);
      siz[u] += siz[v];
      if (siz[son[u]] < siz[v]) son[u] = v;
    }
  }
}
int dfn[200005], dc;
void dfs2(int u) {
  dfn[u] = ++dc;
  if (son[u]) top[son[u]] = top[u], dfs2(son[u]);
  for (int v, p = fir[u]; p; p = nxt[p])
    if ((v = to[p]) != fa[u] && v != son[u]) top[v] = v, dfs2(v);
}
int LCA(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    x = fa[top[x]];
  }
  return dep[x] < dep[y] ? x : y;
}
int stk[200005], tp, dl[200005], dcnt;
bool ont[200005];
bool cmp(int x, int y) { return dfn[x] < dfn[y]; }
void build() {
  tp = 0;
  sort(dl + 1, dl + dcnt + 1, cmp);
  int i, u, lca, tmp = dcnt;
  if (dl[1] != 1) dl[++dcnt] = 1, stk[++tp] = 1;
  for (i = 1; i <= tmp; i++) {
    ont[u = dl[i]] = 1;
    if (tp <= 1 || (lca = LCA(stk[tp], u)) == stk[tp]) {
      stk[++tp] = u;
      continue;
    }
    while (tp > 1 && dep[stk[tp - 1]] >= dep[lca]) {
      adde(stk[tp - 1], stk[tp]);
      tp--;
    }
    if (lca != stk[tp]) {
      adde(lca, stk[tp]);
      stk[tp] = lca;
      dl[++dcnt] = lca;
    }
    stk[++tp] = u;
  }
  while (tp > 1) {
    adde(stk[tp - 1], stk[tp]);
    tp--;
  }
}
int val[200005], f[200005], g[200005], sum[200005], asum;
void CL() {
  for (int u, i = 1; i <= dcnt; i++) {
    u = dl[i];
    fir[u] = val[u] = 0;
    ont[u] = 0;
  }
  dcnt = cnt = 0;
}
vector<int> id[200005];
int w[200005];
void DP1(int u, int ff) {
  sum[u] = val[u];
  g[u] = f[u] = 0;
  for (int v, p = fir[u]; p; p = nxt[p]) {
    if ((v = to[p]) != ff) {
      DP1(v, u);
      f[u] = (1ll * f[u] + 1ll * f[v] + 1ll * sum[v] * cd[p]) % mod;
      sum[u] = (sum[u] + sum[v]) % mod;
    }
  }
}
void DP2(int u, int ff) {
  for (int v, p = fir[u]; p; p = nxt[p]) {
    if ((v = to[p]) != ff) {
      g[v] =
          (1ll * g[u] + 1ll * (1ll * asum + 2ll * mod - 2ll * sum[v]) * cd[p]) %
          mod;
      DP2(v, u);
    }
  }
}
int main() {
  int n, i, j, k, u, v;
  shai();
  n = gi();
  for (i = 1; i <= n; i++) a[i] = gi(), id[a[i]].push_back(i);
  for (i = 1; i < n; i++) {
    u = gi();
    v = gi();
    adde(u, v);
  }
  dfs1(1);
  top[1] = 1;
  dfs2(1);
  memset(fir, 0, sizeof(fir));
  cnt = 0;
  int ans = 0, su;
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j += i) {
      w[j] = (1ll * w[j] + 1ll * i * inv[phi[i]] % mod * mu[j / i]) % mod;
      for (k = 0; k < int(id[j].size()); k++) {
        u = dl[++dcnt] = id[j][k];
        val[u] = phi[a[u]];
      }
    }
    build();
    DP1(1, 0);
    g[1] = f[1];
    asum = sum[1];
    DP2(1, 0);
    su = 0;
    for (j = 1; j <= dcnt; j++)
      if (ont[u = dl[j]]) su = (1ll * su + 1ll * g[u] * val[u]) % mod;
    ans = (1ll * ans + 1ll * su * w[i]) % mod;
    CL();
  }
  ans = 1ll * ans * inv[n] % mod * inv[n - 1] % mod;
  printf("%d\n", (ans + mod) % mod);
}