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 = 200005;
const int mod = 1000000007;
int n, v[maxn], h, firs[maxn], x, y, p[maxn], mu[maxn], phi[maxn], vis[maxn],
    p_cnt, pri[maxn], F[maxn];
int siz[maxn], son[maxn], Top[maxn], f[maxn], ans, dep[maxn], inv_phi[maxn],
    a[maxn], m, id[maxn], id_cnt;
long long dp[maxn], sta[maxn], vv[maxn], va[maxn];
struct edge {
  int too, nex, c;
};
struct gragh {
  edge g[maxn << 1];
  int h, firs[maxn];
  void add(int x, int y, int c) {
    g[++h].nex = firs[x];
    firs[x] = h;
    g[h].too = y;
    g[h].c = c;
    g[++h].nex = firs[y];
    firs[y] = h;
    g[h].too = x;
    g[h].c = c;
  }
} g1, g;
int qui(int a, int b) {
  int s = 1;
  while (b) {
    if (b & 1) s = 1LL * s * a % mod;
    a = 1LL * a * a % mod;
    b >>= 1;
  }
  return s;
}
bool cmp(int a, int b) { return id[a] < id[b]; }
void init() {
  mu[1] = 1;
  phi[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) mu[i] = -1, phi[i] = i - 1, pri[++p_cnt] = i;
    for (int j = 1; j <= p_cnt && i * pri[j] <= n; ++j) {
      vis[i * pri[j]] = 1;
      if (i % pri[j] == 0) {
        phi[i * pri[j]] = phi[i] * pri[j];
        break;
      }
      phi[i * pri[j]] = phi[i] * phi[pri[j]];
      mu[i * pri[j]] = -mu[i];
    }
  }
  for (int i = 1; i <= n; ++i) inv_phi[i] = qui(phi[i], mod - 2);
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; j += i)
      F[j] = (F[j] + 1LL * i * inv_phi[i] * mu[j / i] % mod + mod) % mod;
}
void dfs1(int x) {
  int j, maxs = -1;
  siz[x] = 1;
  for (int i = g1.firs[x]; i; i = g1.g[i].nex) {
    j = g1.g[i].too;
    if (dep[j]) continue;
    dep[j] = dep[x] + 1;
    f[j] = x;
    dfs1(j);
    siz[x] += siz[j];
    if (siz[j] >= maxs) maxs = siz[j], son[x] = j;
  }
}
void dfs2(int x, int Tp) {
  Top[x] = Tp;
  id[x] = ++id_cnt;
  if (!son[x]) return;
  dfs2(son[x], Tp);
  int j;
  for (int i = g1.firs[x]; i; i = g1.g[i].nex) {
    j = g1.g[i].too;
    if (j == f[x] || j == son[x]) continue;
    dfs2(j, j);
  }
}
int lca(int x, int y) {
  while (Top[x] != Top[y]) {
    if (dep[Top[x]] > dep[Top[y]]) swap(x, y);
    y = f[Top[y]];
  }
  return (dep[x] < dep[y]) ? x : y;
}
int d(int x, int y) { return dep[x] + dep[y] - 2 * dep[lca(x, y)]; }
void DP(int x) {
  int j, vl, t1 = 0, t2 = 0, len;
  dp[x] = 0;
  va[x] = 0;
  vv[x] = vl = vis[x] ? v[x] : 0;
  for (int i = g.firs[x]; i; i = g.g[i].nex) {
    j = g.g[i].too;
    if (dep[j] < dep[x]) continue;
    DP(j);
    len = g.g[i].c;
    dp[x] = (dp[x] + dp[j]) % mod;
    dp[x] = (dp[x] + 1LL * vl * (vv[j] * len % mod + va[j])) % mod;
    dp[x] =
        (dp[x] + 1LL * t2 * vv[j] + 1LL * t1 * (vv[j] * len % mod + va[j])) %
        mod;
    vv[x] = (vv[x] + vv[j]) % mod;
    va[x] = (va[x] + va[j] + vv[j] * len % mod) % mod;
    t1 = (t1 + vv[j]) % mod;
    t2 = (t2 + va[j] + vv[j] * len % mod) % mod;
  }
}
int ask(int x) {
  int m = 0, Tp = 0;
  for (int i = 1; i <= n / x; i++) a[++m] = p[i * x];
  g.h = 0;
  sort(a + 1, a + 1 + m, cmp);
  g.firs[1] = 0;
  for (int i = 1; i <= m; ++i) g.firs[a[i]] = 0, vis[a[i]] = 1;
  for (int i = 2; i <= m; ++i) g.firs[lca(a[i], a[i - 1])] = 0;
  sta[++Tp] = 1;
  int st = 1;
  if (a[1] == 1) st = 2;
  for (int i = st; i <= m; ++i) {
    int LCA = lca(sta[Tp], a[i]);
    while (Tp > 1 && LCA != sta[Tp]) {
      if (sta[Tp - 1] == LCA) {
        g.add(sta[Tp], sta[Tp - 1], dep[sta[Tp]] - dep[sta[Tp - 1]]);
        Tp--;
        break;
      }
      if (id[sta[Tp - 1]] < id[LCA]) {
        g.add(LCA, sta[Tp], dep[sta[Tp]] - dep[LCA]);
        sta[Tp] = LCA;
        break;
      }
      g.add(sta[Tp], sta[Tp - 1], dep[sta[Tp]] - dep[sta[Tp - 1]]);
      Tp--;
    }
    sta[++Tp] = a[i];
  }
  while (Tp > 1)
    g.add(sta[Tp], sta[Tp - 1], dep[sta[Tp]] - dep[sta[Tp - 1]]), Tp--;
  DP(1);
  for (int i = 1; i <= m; ++i) vis[a[i]] = 0;
  return dp[1] * 2 % mod;
}
inline int read() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x;
}
int main() {
  scanf("%d", &n);
  init();
  for (int i = 1; i <= n; ++i) v[i] = read(), p[v[i]] = i, v[i] = phi[v[i]];
  for (int i = 1; i < n; ++i) {
    x = read(), y = read();
    g1.add(x, y, 1);
  }
  dep[1] = 1;
  dfs1(1);
  dfs2(1, 1);
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; ++i) ans = (ans + 1LL * F[i] * ask(i) % mod) % mod;
  ans = 1LL * ans * qui(1LL * n * (n - 1) % mod, mod - 2) % mod;
  printf("%d\n", ans);
  return 0;
}