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 long long read() {
  long long f = 1, ans = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + c - '0';
    c = getchar();
  }
  return f * ans;
}
const long long MAXN = 4e5 + 11;
long long phi[MAXN], N, A[MAXN], id[MAXN], pri[MAXN], mu[MAXN], v[MAXN],
    inv[MAXN], V[MAXN];
vector<long long> vec[MAXN], Vec[MAXN];
void Init() {
  mu[1] = 1, phi[1] = 1;
  V[1] = 1;
  for (long long i = 2; i <= N; i++) {
    if (!v[i]) {
      pri[++pri[0]] = i, v[i] = i, mu[i] = -1, phi[i] = i - 1;
      V[i] = inv[i - 1] * i % 1000000007;
    }
    for (long long j = 1; j <= pri[0] && i <= N / pri[j]; j++) {
      v[i * pri[j]] = pri[j];
      if (!(i % pri[j])) {
        phi[i * pri[j]] = phi[i] * pri[j];
        V[i * pri[j]] = V[i];
        mu[i * pri[j]] = 0;
        break;
      }
      phi[i * pri[j]] = phi[i] * (pri[j] - 1);
      mu[i * pri[j]] = -mu[i];
      V[i * pri[j]] = V[i] * V[pri[j]] % 1000000007;
    }
  }
  return;
}
long long ksm(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans *= a, ans %= 1000000007;
    a *= a, a %= 1000000007;
    b >>= 1;
  }
  return ans;
}
long long in[MAXN], out[MAXN], rev[MAXN], dep[MAXN], tot, Log[MAXN], F[MAXN],
    sta[MAXN], Q[MAXN], q[MAXN], f[MAXN];
vector<long long> C;
void dfs(long long u, long long fath) {
  in[u] = ++tot, rev[tot] = u, dep[u] = dep[fath] + 1;
  for (auto v : vec[u])
    if (v != fath) {
      dfs(v, u);
      rev[++tot] = u;
    }
  out[u] = tot;
}
bool cmp(long long x, long long y) { return in[x] < in[y]; }
struct RMQ {
  long long Minn[MAXN][21], ps[MAXN][21];
  void init() {
    for (long long i = 1; i <= tot; i++)
      Minn[i][0] = dep[rev[i]], ps[i][0] = rev[i];
    for (long long j = 1; (1 << j) <= tot; j++)
      for (long long i = 1; i + (1 << j) - 1 <= tot; i++) {
        if (Minn[i][j - 1] <= Minn[i + (1 << (j - 1))][j - 1])
          Minn[i][j] = Minn[i][j - 1], ps[i][j] = ps[i][j - 1];
        else
          Minn[i][j] = Minn[i + (1 << (j - 1))][j - 1],
          ps[i][j] = ps[i + (1 << (j - 1))][j - 1];
      }
    return;
  }
  long long Qlca(long long u, long long v) {
    if (in[u] > in[v]) swap(u, v);
    long long L = in[u], R = in[v], len = R - L + 1, k = Log[len];
    long long w1 = Minn[L][k], w2 = Minn[R - (1 << k) + 1][k];
    if (w1 <= w2) return ps[L][k];
    return ps[R - (1 << k) + 1][k];
  }
} S;
void ins(long long x) {
  if (sta[0] == 1) {
    if (sta[1] != x) sta[++sta[0]] = x;
    return;
  }
  long long now = S.Qlca(x, sta[sta[0]]);
  while (sta[0] > 1 && dep[sta[sta[0] - 1]] >= dep[now])
    Vec[sta[sta[0] - 1]].push_back(sta[sta[0]]), sta[0]--;
  if (dep[sta[sta[0]]] > dep[now]) Vec[now].push_back(sta[sta[0]]), sta[0]--;
  if (sta[sta[0]] != now) sta[++sta[0]] = now;
  sta[++sta[0]] = x;
  return;
}
void build() {
  sta[0] = 0;
  sta[++sta[0]] = 1;
  for (long long i = 1; i <= Q[0]; i++) ins(Q[i]);
  while (sta[0] > 1) Vec[sta[sta[0] - 1]].push_back(sta[sta[0]]), sta[0]--;
  return;
}
long long S1[MAXN], S2[MAXN], res, D;
void Clear() {
  for (auto v : C) Vec[v].clear(), S1[v] = S2[v] = 0;
  C.clear();
  return;
}
void dfs1(long long u) {
  long long now1 = 0, now2 = 0;
  C.push_back(u);
  for (auto v : Vec[u]) {
    dfs1(v);
    if (!(A[u] % D))
      now2 += (S1[v] * phi[A[u]]) % 1000000007,
          now2 -= phi[A[u]] * S2[v] % 1000000007 * dep[u] % 1000000007,
          now2 = ((now2 % 1000000007) + 1000000007) % 1000000007;
    now1 -= 2 * dep[u] * S2[u] % 1000000007 * S2[v] % 1000000007,
        now1 = (now1 % 1000000007 + 1000000007) % 1000000007;
    now1 += S1[u] * S2[v], now1 += S2[u] * S1[v], now1 %= 1000000007;
    S1[u] += S1[v], S2[u] += S2[v];
    S1[u] %= 1000000007, S2[u] %= 1000000007;
  }
  if (!(A[u] % D)) S1[u] += dep[u] * phi[A[u]] % 1000000007, S2[u] += phi[A[u]];
  S1[u] %= 1000000007, S2[u] %= 1000000007;
  res += (now1 + now2) * 2 % 1000000007;
  return;
}
signed main() {
  N = read();
  for (long long i = 1; i <= N; i++) A[i] = read(), id[A[i]] = i;
  inv[1] = 1;
  for (long long i = 2; i <= N; i++)
    inv[i] = (1000000007 - 1000000007 / i) * inv[1000000007 % i] % 1000000007;
  for (long long i = 1; i < N; i++) {
    long long u = read(), v = read();
    vec[u].push_back(v), vec[v].push_back(u);
  }
  Init();
  dfs(1, 0);
  Log[0] = -1;
  for (long long i = 1; i <= tot; i++) Log[i] = Log[i >> 1] + 1;
  S.init();
  for (long long i = 1; i <= N; i++) {
    D = i;
    Q[0] = 0, sta[0] = 0;
    bool ff = 0;
    for (long long j = i; j <= N; j += i) Q[++Q[0]] = id[j];
    sort(Q + 1, Q + Q[0] + 1, cmp);
    build();
    res = 0;
    dfs1(1);
    F[i] = res;
    Clear();
  }
  for (long long i = 1; i <= N; i++)
    for (long long j = i; j <= N; j += i)
      f[i] += mu[j / i] * F[j],
          f[i] = (f[i] % 1000000007 + 1000000007) % 1000000007;
  long long Ans = 0;
  for (long long i = 1; i <= N; i++) Ans += V[i] * f[i], Ans %= 1000000007;
  printf("%lld\n",
         Ans * ksm(N * (N - 1) % 1000000007, 1000000007 - 2) % 1000000007);
  return 0;
}