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 N = 201000, mod = 1e9 + 7;
int add(int x, int y) {
  x += y;
  while (x >= mod) x -= mod;
  return x;
}
int power(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (long long)ans * x % mod;
    x = (long long)x * x % mod;
    y >>= 1;
  }
  return ans;
}
struct Edge {
  int next, end;
} edge[N << 1];
vector<int> q[N], q2[N];
bool bo[N];
int pri[N], phi[N], mu[N], len, fx[N];
int dfn[N], tot, mn[N << 1][21], lg2[N << 1], dep[N];
int p[N], n, a[N], first[N], efn, inv[N];
int f[N], g[N], sta[N], siz, num[N], ans;
void addedge(int, int);
void dfs(int, int);
bool cmp(int x, int y) { return dfn[fx[x]] < dfn[fx[y]]; }
void init(int);
int lca(int, int);
int main() {
  scanf("%d", &n);
  init(n);
  for (int i = 1; i <= n; i++) p[i] = i;
  lg2[0] = -1;
  for (int i = 1; i <= n + n; i++) lg2[i] = lg2[i / 2] + 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    fx[a[i]] = i;
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    addedge(x, y);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) q2[j].push_back(i);
  }
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < q2[p[i]].size(); j++)
      q[q2[p[i]][j]].push_back(fx[p[i]]);
  }
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= tot; j++) {
      int w = min(tot, j + (1 << i - 1));
      mn[j][i] =
          dfn[mn[j][i - 1]] < dfn[mn[w][i - 1]] ? mn[j][i - 1] : mn[w][i - 1];
    }
  for (int i = 1; i <= n; i++) {
    siz = 0;
    int sum = 0;
    for (int j = 1; j < q[i].size(); j++) {
      int w = lca(q[i][j - 1], q[i][j]);
      int cnt = phi[a[q[i][j - 1]]];
      while (siz > 0 && dep[w] <= dep[sta[siz]]) {
        f[i] = add(f[i],
                   mod - (long long)dep[sta[siz]] * cnt % mod * num[siz] % mod);
        cnt = add(cnt, num[siz]);
        siz--;
      }
      num[++siz] = cnt;
      sta[siz] = w;
    }
    int cnt = phi[a[q[i][q[i].size() - 1]]];
    while (siz) {
      f[i] = add(f[i],
                 mod - (long long)dep[sta[siz]] * cnt % mod * num[siz] % mod);
      cnt = add(cnt, num[siz]);
      siz--;
    }
    f[i] = add(f[i], f[i]);
    for (int j = 0; j < q[i].size(); j++) {
      sum = add(sum, phi[a[q[i][j]]]);
    }
    for (int j = 0; j < q[i].size(); j++)
      f[i] = add(f[i], (long long)add(sum, mod - phi[a[q[i][j]]]) *
                           phi[a[q[i][j]]] % mod * dep[q[i][j]] % mod);
    f[i] = add(f[i], f[i]);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; i * j <= n; j++)
      g[i] = add(g[i], (long long)mu[j] * f[i * j] % mod);
  for (int i = 1; i <= n; i++)
    ans = add(ans, (long long)g[i] * i % mod * inv[phi[i]] % mod);
  printf("%d\n",
         (long long)ans * power((long long)n * (n - 1) % mod, mod - 2) % mod);
  return 0;
}
void init(int p) {
  inv[1] = 1;
  for (int i = 2; i <= p; i++)
    inv[i] = mod - (long long)mod / i * inv[mod % i] % mod;
  phi[1] = 1;
  mu[1] = 1;
  for (int i = 2; i <= p; i++) {
    if (bo[i] == 0) pri[++len] = i, phi[i] = i - 1, mu[i] = mod - 1;
    for (int j = 1; j <= len && i * pri[j] <= p; j++) {
      int u = i * pri[j];
      bo[u] = 1;
      if (i % pri[j])
        phi[u] = phi[i] * phi[pri[j]], mu[u] = mod - mu[i];
      else {
        phi[u] = phi[i] * pri[j];
        break;
      }
    }
  }
}
void addedge(int x, int y) {
  edge[++efn].end = y;
  edge[efn].next = first[x];
  first[x] = efn;
  edge[++efn].end = x;
  edge[efn].next = first[y];
  first[y] = efn;
}
void dfs(int x, int y) {
  dfn[x] = ++tot;
  dep[x] = dep[y] + 1;
  mn[tot][0] = x;
  for (int h = first[x]; h; h = edge[h].next) {
    int u = edge[h].end;
    if (u != y) {
      dfs(u, x);
      mn[++tot][0] = x;
    }
  }
}
int lca(int x, int y) {
  x = dfn[x];
  y = dfn[y];
  int w = (y - x + 1);
  w = lg2[w];
  return dfn[mn[x][w]] < dfn[mn[y - (1 << w) + 1][w]] ? mn[x][w]
                                                      : mn[y - (1 << w) + 1][w];
}