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 long long MOD = 1e9 + 7;
const int N = 2e5 + 10, K = 22;
void Init();
long long Calc(int dg);
int BuildVirt(int dg);
void dfs1(int u, int ff);
int lca(int u, int v);
long long dfs2(int u, int dg);
long long dfs3(int u, long long cur, long long Sum);
struct Edge {
  int to, dis, nx;
} edg[N * 3];
vector<int> keyp[N], g[N], fact[N];
int a[N], n, ky[N], kn, sk[N], skn, g2[N], pn, prime[N], sz[N], dfn[N],
    dfs_clock = 0, dep[N], jp[N][K], edgn = 0;
int val[N];
bool vis[N];
long long prod[N], inv[N], phi[N], pr[N], s[N];
bool cmpdfn(int u, int v) { return dfn[u] < dfn[v]; }
void AddEdg(int ff, int u) {
  edg[edgn] = (Edge){u, dep[u] - dep[ff], g2[ff]};
  g2[ff] = edgn++;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  Init();
  for (int i = 1, u, v; i < n; ++i) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs1(1, -1);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    long long f = Calc(i), g = prod[i];
    ans = (ans + f * g) % MOD;
  }
  ans = ans * inv[n] % MOD * inv[n - 1] % MOD;
  cout << ans << endl;
  return 0;
}
void Init() {
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; ++i) inv[i] = (MOD - inv[MOD % i]) * (MOD / i) % MOD;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j < K; ++j) jp[i][j] = -1;
  phi[1] = prod[1] = 1;
  for (int i = 1; i <= n; ++i) pr[i] = i;
  pn = 0;
  for (int i = 2; i <= n; ++i) {
    if (pr[i] == i) prime[pn++] = i;
    for (int j = 0; j < pn && prime[j] <= pr[i] && i <= n / prime[j]; ++j)
      pr[i * prime[j]] = prime[j];
    int pre = i / pr[i];
    if (pr[i] != pr[pre])
      prod[i] = prod[pre] * inv[pr[i] - 1] % MOD,
      phi[i] = phi[pre] * (pr[i] - 1);
    else
      prod[i] = 0, phi[i] = phi[pre] * pr[i];
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; j += i) fact[j].push_back(i);
  for (int i = 1; i <= n; ++i)
    for (int ai = a[i], j = 0; j < fact[ai].size(); ++j)
      keyp[fact[ai][j]].push_back(i);
}
long long Calc(int dg) {
  int rt = BuildVirt(dg);
  long long initres = dfs2(rt, dg);
  return dfs3(rt, initres, s[rt]);
}
int BuildVirt(int dg) {
  for (int i = 0; i < (kn = keyp[dg].size()); ++i)
    vis[ky[i] = keyp[dg][i]] = true;
  sort(ky, ky + kn, cmpdfn);
  for (int i = 0, m = kn, c; i + 1 < m; ++i)
    if (!vis[c = lca(ky[i], ky[i + 1])]) vis[ky[kn++] = c] = true;
  sort(ky, ky + kn, cmpdfn);
  edgn = 0;
  for (int i = 0; i < kn; ++i) g2[ky[i]] = -1;
  skn = 0;
  sk[skn++] = ky[0];
  for (int i = 1; i < kn; sk[skn++] = ky[i++]) {
    while (dfn[sk[skn - 1]] + sz[sk[skn - 1]] <= dfn[ky[i]]) --skn;
    AddEdg(sk[skn - 1], ky[i]);
  }
  for (int i = 0; i < kn; ++i) vis[ky[i]] = false;
  return ky[0];
}
void dfs1(int u, int ff) {
  sz[u] = 1;
  dfn[u] = ++dfs_clock;
  jp[u][0] = ff;
  if (ff != -1) {
    for (int k = 0; jp[jp[u][k]][k] != -1; ++k) jp[u][k + 1] = jp[jp[u][k]][k];
    dep[u] = dep[ff] + 1;
  } else
    dep[u] = 0;
  for (int i = 0, v; i < g[u].size(); ++i)
    if ((v = g[u][i]) != ff) {
      dfs1(v, u);
      sz[u] += sz[v];
    }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int step = dep[u] - dep[v], i = 0; step; step >>= 1, ++i)
    if (step & 1) u = jp[u][i];
  if (u == v) return u;
  for (int k = 20; ~k; --k)
    if (jp[u][k] != jp[v][k]) u = jp[u][k], v = jp[v][k];
  return jp[u][0];
}
long long dfs2(int u, int dg) {
  if (a[u] % dg == 0)
    val[u] = phi[a[u]];
  else
    val[u] = 0;
  s[u] = val[u];
  long long sum = 0;
  for (int i = g2[u]; ~i; i = edg[i].nx) {
    Edge e = edg[i];
    sum += (dfs2(e.to, dg) + s[e.to] * e.dis) % MOD;
    s[u] = (s[u] + s[e.to]) % MOD;
  }
  return sum;
}
long long dfs3(int u, long long cur, long long Sum) {
  long long res = cur * val[u] % MOD;
  for (int i = g2[u]; ~i; i = edg[i].nx) {
    Edge e = edg[i];
    long long nx =
        (cur + e.dis * ((Sum - s[e.to] + MOD - s[e.to]) % MOD)) % MOD;
    res = (res + dfs3(e.to, nx, Sum)) % MOD;
  }
  return res;
}