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>
inline int read() {
  int res = 0;
  bool bo = 0;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    bo = 1;
  else
    res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  return bo ? ~res + 1 : res;
}
template <class T>
inline void Swap(T &a, T &b) {
  a ^= b;
  b ^= a;
  a ^= b;
}
const int N = 2e5 + 5, M = N << 1, LogN = 20, ZZQ = 1e9 + 7;
int n, a[N], ecnt, nxt[M], adj[N], go[M], phi[N], tot, pri[N], f[N], dfn[N], T,
    dep[N], fa[N][LogN], virn, vir[N], tn, tvir[N], top, stk[N], sum[N],
    virfa[N], to[N], res[N], ans;
bool mark[N];
int qpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = 1ll * res * a % ZZQ;
    a = 1ll * a * a % ZZQ;
    b >>= 1;
  }
  return res;
}
void sieve() {
  int i, j;
  mark[0] = mark[phi[1] = f[1] = 1] = 1;
  for (i = 1; i <= n; i++) {
    if (!mark[i])
      phi[pri[++tot] = i] = i - 1, f[i] = 1ll * i * qpow(i - 1, ZZQ - 2) % ZZQ;
    for (j = 1; j <= tot; j++) {
      if (1ll * i * pri[j] > n) break;
      mark[i * pri[j]] = 1;
      if (i % pri[j] == 0) {
        f[i * pri[j]] = f[i];
        phi[i * pri[j]] = phi[i] * pri[j];
        break;
      } else {
        phi[i * pri[j]] = phi[i] * (pri[j] - 1);
        f[i * pri[j]] =
            1ll * f[i] * pri[j] % ZZQ * qpow(pri[j] - 1, ZZQ - 2) % ZZQ;
      }
    }
  }
}
void add_edge(int u, int v) {
  nxt[++ecnt] = adj[u];
  adj[u] = ecnt;
  go[ecnt] = v;
  nxt[++ecnt] = adj[v];
  adj[v] = ecnt;
  go[ecnt] = u;
}
void dfs(int u, int fu) {
  int i;
  dfn[u] = ++T;
  dep[u] = dep[fa[u][0] = fu] + 1;
  for (i = 0; i <= 16; i++) fa[u][i + 1] = fa[fa[u][i]][i];
  for (int e = adj[u], v; e; e = nxt[e])
    if ((v = go[e]) != fu) dfs(v, u);
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) Swap(u, v);
  int i;
  for (i = 17; i >= 0; i--) {
    if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
    if (u == v) return u;
  }
  for (i = 17; i >= 0; i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
inline bool comp(int a, int b) { return dfn[a] < dfn[b]; }
void build_virtree() {
  int i;
  std::sort(vir + 1, vir + virn + 1, comp);
  tn = virn;
  for (i = 1; i <= virn; i++) tvir[i] = vir[i], sum[vir[i]] = phi[a[vir[i]]];
  top = 0;
  for (i = 1; i <= tn; i++) {
    int u = vir[i];
    if (!top) {
      virfa[stk[++top] = u] = 0;
      continue;
    }
    int w = lca(stk[top], u);
    while (dep[w] < dep[stk[top]]) {
      if (dep[w] > dep[stk[top - 1]]) virfa[stk[top]] = w;
      top--;
    }
    if (w != stk[top])
      virfa[w] = stk[top], stk[++top] = w, vir[++virn] = w, sum[w] = 0;
    virfa[stk[++top] = u] = w;
  }
  std::sort(vir + 1, vir + virn + 1, comp);
}
void DP(int x) {
  int i;
  for (i = virn; i >= 2; i--)
    sum[virfa[vir[i]]] = (sum[virfa[vir[i]]] + sum[vir[i]]) % ZZQ;
  for (i = virn; i >= 2; i--)
    res[x] = (2ll * sum[vir[i]] * (sum[vir[1]] - sum[vir[i]] + ZZQ) % ZZQ *
                  (dep[vir[i]] - dep[virfa[vir[i]]]) +
              res[x]) %
             ZZQ;
}
int main() {
  int i, j, x, y;
  n = read();
  sieve();
  for (i = 1; i <= n; i++) to[a[i] = read()] = i;
  for (i = 1; i <= n - 1; i++) x = read(), y = read(), add_edge(x, y);
  dfs(1, 0);
  for (i = 1; i <= n; i++) {
    virn = 0;
    for (j = i; j <= n; j += i) vir[++virn] = to[j];
    build_virtree();
    DP(i);
  }
  for (i = n; i >= 1; i--)
    for (j = (i << 1); j <= n; j += i) res[i] = (res[i] - res[j] + ZZQ) % ZZQ;
  for (i = 1; i <= n; i++) ans = (1ll * res[i] * f[i] + ans) % ZZQ;
  std::cout << 1ll * ans * qpow(1ll * n * (n - 1) % ZZQ, ZZQ - 2) % ZZQ
            << std::endl;
  return 0;
}