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 mo = 1e9 + 7;
vector<int> G[200005], V[200005], E[200005];
int n, m, a[200005], b[200005], phi[200005], pr[200005], P[200005][10],
    lp[200005], f[20][200005], lt[200005], rt[200005], d[200005], st[200005],
    top, vis[200005], clk, F[200005], H[200005], ans[200005], I[200005],
    w[200005], lw;
long long fpm(long long x, long long y) {
  long long s = 1;
  while (y) {
    if (y & 1) s = (s * x) % mo;
    y >>= 1, x = (x * x) % mo;
  }
  return s;
}
bool cmp(int x, int y) { return lt[x] < lt[y]; }
void dfs(int t, int fa) {
  int i;
  d[t] = d[fa] + 1;
  lt[t] = ++m, f[0][t] = fa;
  for (i = 0; i < G[t].size(); i++) {
    if (G[t][i] == fa) continue;
    dfs(G[t][i], t);
  }
  rt[t] = m;
}
int lca(int x, int y) {
  int i;
  for (i = 19; i >= 0; i--)
    if (f[i][x] && (lt[y] < lt[f[i][x]] || lt[y] > rt[f[i][x]])) x = f[i][x];
  return (lt[y] < lt[x] || lt[y] > rt[x]) ? f[0][x] : x;
}
void link(int x, int y, int z) {
  if (vis[x] != clk) E[x].clear(), V[x].clear(), vis[x] = clk;
  if (vis[y] != clk) E[y].clear(), V[y].clear(), vis[y] = clk;
  E[x].push_back(y), V[x].push_back(z);
}
void dp(int t, int p) {
  int i;
  F[t] = (a[t] % p == 0 ? phi[a[t]] : 0), H[t] = 0;
  for (i = 0; i < E[t].size(); i++) {
    dp(E[t][i], p);
    H[E[t][i]] = (H[E[t][i]] + 1LL * V[t][i] * F[E[t][i]]) % mo;
    ans[p] = (ans[p] + 1LL * F[t] * H[E[t][i]]) % mo;
    ans[p] = (ans[p] + 1LL * H[t] * F[E[t][i]]) % mo;
    F[t] = (F[t] + F[E[t][i]]) % mo;
    H[t] = (H[t] + H[E[t][i]]) % mo;
  }
}
int main() {
  int i, j, x, y, z;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    scanf("%d", &a[i]), b[a[i]] = i, I[i] = fpm(i, mo - 2);
  for (i = 2; i <= n; i++) {
    scanf("%d %d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (i = 1; i <= n; i++) phi[i] = i;
  for (i = 2; i <= n; i++) {
    if (pr[i]) continue;
    for (j = i; j <= n; j += i) {
      phi[j] = phi[j] / i * (i - 1), pr[j] = 1;
      P[j][++lp[j]] = i;
    }
  }
  dfs(1, 0);
  for (i = 1; i < 20; i++)
    for (j = 1; j <= n; j++) f[i][j] = f[i - 1][f[i - 1][j]];
  for (i = 1; i <= n; i++) {
    lw = 0, ++clk;
    for (j = i; j <= n; j += i)
      w[++lw] = b[j], vis[b[j]] = clk, E[b[j]].clear(), V[b[j]].clear();
    sort(w + 1, w + lw + 1, cmp);
    st[top = 1] = w[1];
    for (j = 2; j <= lw; j++) {
      z = lca(w[j], st[top]), x = 0;
      while (top && d[st[top]] >= d[z]) {
        if (x) link(st[top], x, d[x] - d[st[top]]);
        x = st[top], top--;
      }
      if (x != z) link(z, x, d[x] - d[z]);
      st[++top] = z, st[++top] = w[j];
    }
    while (top > 1)
      link(st[top - 1], st[top], d[st[top]] - d[st[top - 1]]), top--;
    dp(st[1], i);
  }
  for (i = n; i >= 1; i--)
    for (j = i + i; j <= n; j += i) ans[i] = (ans[i] - ans[j] + mo) % mo;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= lp[i]; j++)
      ans[i] = 1LL * ans[i] * P[i][j] % mo * I[P[i][j] - 1] % mo;
  int res = 0;
  for (i = 1; i <= n; i++) res = (res + ans[i]) % mo;
  res = 2LL * res * I[n] % mo * I[n - 1] % mo;
  cout << res;
  return 0;
}