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;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T, class U>
inline void print(T first, U second) {
  printsp(first);
  println(second);
}
template <class T, class U, class V>
inline void print(T first, U second, V z) {
  printsp(first);
  printsp(second);
  println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int phi[200010], flag[200010], prime[200010], ff[200010];
int a[200010], dp[200010], head[200010], fac[20];
int to[200010 << 1], nxt[200010 << 1], E, id[200010];
int st[200010], ed[200010], tot, val[200010], ans[200010], q[200010];
int vst[200010], fflag[200010], vflag, inv[200010], tval[200010], pa[200010];
vector<int> V[200010];
void add_edge(int u, int v) {
  to[E] = v;
  nxt[E] = head[u];
  head[u] = E++;
}
struct Cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) const {
    if (dp[a.first] != dp[b.first]) return dp[a.first] > dp[b.first];
    return a.second < b.second;
  }
};
int p[200010][20];
set<pair<int, int>, Cmp> S;
struct LCA {
  void dfs(int u = 1, int fa = 0) {
    p[u][0] = fa;
    dp[u] = dp[fa] + 1;
    st[u] = ++tot;
    for (int i = 1; i < 18; i++) p[u][i] = p[p[u][i - 1]][i - 1];
    for (int e = head[u]; e != -1; e = nxt[e]) {
      int v = to[e];
      if (v == fa) continue;
      dfs(v, u);
    }
    ed[u] = tot;
  }
  int k_th(int u, int k) {
    for (int i = 0; i < 18; i++) {
      if (k & (1 << i)) u = p[u][i];
    }
    return u;
  }
  int lca(int a, int b) {
    if (dp[a] > dp[b]) swap(a, b);
    b = k_th(b, dp[b] - dp[a]);
    if (a == b) return a;
    for (int i = 18; i >= 0; i--) {
      if (p[a][0] == p[b][0]) break;
      if (p[a][i] != p[b][i]) a = p[a][i], b = p[b][i];
    }
    return p[a][0];
  }
} lca;
int cmp(int u, int v) { return st[u] < st[v]; }
int sum[200010], tmp[200010];
void dfs(int u, int k) {
  sum[u] = 0;
  long long mid = 0, tp = 0;
  for (int e = head[u]; ~e; e = nxt[e]) {
    int v = to[e];
    dfs(v, k);
    mid += (long long)sum[v] * sum[v] % 1000000007;
    tp += sum[v];
  }
  mid %= 1000000007;
  tp %= 1000000007;
  sum[u] = (tp + a[u] * (fflag[u] == vflag)) % 1000000007;
  tmp[u] = (tp * tp - mid + 2LL * tp * a[u] * (fflag[u] == vflag)) % 1000000007;
  if (tmp[u] < 0) tmp[u] += 1000000007;
  ans[k] -= (long long)dp[u] * tmp[u] % 1000000007;
  if (ans[k] < 0) ans[k] += 1000000007;
}
int main() {
  int n, np = 0, u, v;
  memset(head, -1, sizeof(head));
  ff[1] = tval[1] = 1;
  phi[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < 200010; i++)
    inv[i] = (long long)1000000007 / i * (1000000007 - inv[1000000007 % i]) %
             1000000007;
  for (int i = 2; i < 200010; i++) {
    if (!flag[i]) prime[np++] = i, flag[i] = i;
    for (int j = 0; j < np && prime[j] * i < 200010; j++) {
      flag[prime[j] * i] = prime[j];
      if (flag[i] == prime[j]) break;
    }
    int v = i / flag[i];
    if (flag[v] == flag[i])
      ff[i] = ff[v], tval[i] = tval[v], phi[i] = phi[v] * flag[i];
    else
      ff[i] = ff[v] * flag[i],
      tval[i] = (long long)tval[v] * flag[i] % 1000000007 * inv[(flag[i] - 1)] %
                1000000007,
      phi[i] = phi[v] * (flag[i] - 1);
  }
  gn(n);
  for (int i = 1; i <= n; i++) gn(a[i]);
  for (int i = 1; i < n; i++) {
    gn(u, v);
    add_edge(u, v);
    add_edge(v, u);
  }
  lca.dfs();
  for (int i = 0; i < n; i++) id[i] = i + 1;
  sort(id, id + n, cmp);
  val[0] = 1;
  for (int k = 0; k < n; k++) {
    int cnt = 0, i = id[k];
    for (int u = a[i]; u > 1;) {
      int v = flag[u];
      while (u % v == 0) u /= v;
      fac[cnt++] = v;
    }
    V[1].push_back(i);
    for (int j = 1; j < 1 << cnt; j++) {
      val[j] = val[j ^ (j & -j)] * fac[(__builtin_ctz(j))];
      V[val[j]].push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) a[i] = phi[a[i]];
  memset(head, -1, sizeof head);
  for (int i = 1; i <= n; i++)
    if (V[i].size() > 1) {
      int sum = 0, nn = V[i].size();
      for (int j = 0; j < nn; j++) id[j] = V[i][j];
      for (int j = 0; j < nn; j++) sum = (sum + a[id[j]]) % 1000000007;
      ans[i] = 0;
      for (int j = 0; j < nn; j++)
        ans[i] = (ans[i] + (long long)dp[id[j]] * a[id[j]] % 1000000007 *
                               (sum + 1000000007 - a[id[j]])) %
                 1000000007;
      ++vflag;
      int qb = 0;
      for (int j = 0; j < nn; j++)
        pa[id[j]] = -1, vst[id[j]] = vflag, fflag[id[j]] = vflag,
        q[qb++] = id[j];
      int root = lca.lca(id[0], id[nn - 1]);
      for (int j = 1; j < nn; j++) {
        u = lca.lca(id[j - 1], id[j]);
        if (vst[u] != vflag) vst[u] = vflag, q[qb++] = u;
        pa[id[j]] = u;
        v = id[j - 1];
        if (v != u) {
          while (pa[v] != -1) {
            if (dp[pa[v]] <= dp[u]) break;
            v = pa[v];
          }
          if (pa[v] != u) pa[u] = pa[v], pa[v] = u;
        }
      }
      for (int j = 0; j < qb; j++) head[q[j]] = -1;
      E = 0;
      for (int j = 0; j < qb; j++)
        if (pa[q[j]] != -1) add_edge(pa[q[j]], q[j]);
      dfs(root, i);
    }
  long long res = 0;
  for (int i = n; i >= 1; i--) {
    for (int j = i << 1; j <= n; j += i)
      ans[i] = (ans[i] + 1000000007 - ans[j]) % 1000000007;
    res += (long long)ans[i] * tval[i] % 1000000007;
    res %= 1000000007;
  }
  println(2LL * res * inv[n] % 1000000007 * inv[n - 1] % 1000000007);
  return 0;
}