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;
int p1 = 1000000, p2 = 0;
char buf[1000005], wb[1000005];
int gc() {
  if (p1 >= 1000000) fread(buf, 1, 1000000, stdin), p1 = 0;
  return buf[p1++];
}
long long getint() {
  long long ret = 0, flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    ret = (ret << 3) + (ret << 1) + c - '0';
    c = getchar();
  }
  return ret * flag;
}
void pc(char x) {
  if (p2 >= 1000000) fwrite(wb, 1, 1000000, stdout), p2 = 0;
  wb[p2++] = x;
}
void wrt(long long x) {
  if (x < 0) pc('-'), x = -x;
  int c[24] = {0};
  if (!x) return pc('0'), void();
  while (x) c[++c[0]] = x % 10, x /= 10;
  while (c[0]) pc(c[c[0]--] + '0');
}
long long ksm(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % int(1e9 + 7);
    a = a * a % int(1e9 + 7), b >>= 1;
  }
  return ret;
}
int n, a[200005];
struct edge {
  int ne, v;
} e[400005];
int head[200005], cnt;
void add(int u, int v) {
  ++cnt;
  e[cnt].v = v;
  e[cnt].ne = head[u];
  head[u] = cnt;
}
int po[200005];
int dep[200005], fa[200005], p[400005][20], rd[400005], sign;
void dfs(int x, int prt) {
  fa[x] = prt, dep[x] = dep[prt] + 1;
  p[x][0] = prt, rd[x] = ++sign;
  for (int i = 1; i < 20; i++) p[x][i] = p[p[x][i - 1]][i - 1];
  for (int i = head[x]; i; i = e[i].ne) {
    int y = e[i].v;
    if (y == prt) continue;
    dfs(y, x);
  }
}
int LCA(int x, int y) {
  if (!x || !y) return x | y;
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = log2(dep[x] - dep[y]); i >= 0; i--) {
    if (dep[p[x][i]] >= dep[y]) x = p[x][i];
  }
  if (x == y) return x;
  for (int i = log2(dep[x]); i >= 0; i--) {
    if (p[x][i] ^ p[y][i]) x = p[x][i], y = p[y][i];
  }
  return p[x][0];
}
int prim[200005];
long long mul[200005], phi[200005];
bool vst[200005];
vector<int> vec[200005];
bool cmp(int x, int y) { return rd[x] < rd[y]; }
bool vt[200005];
long long s1[200005], s2[200005], ans;
void dfs1(int x, int prt, long long &ret) {
  if (vt[x])
    s1[x] = phi[a[x]], s2[x] = phi[a[x]] * dep[x] % int(1e9 + 7), vt[x] = 0;
  else
    s1[x] = s2[x] = 0;
  for (auto y : vec[x]) {
    if (y == prt) continue;
    dfs1(y, x, ret), ret = (ret + s2[x] * s1[y] % int(1e9 + 7) +
                            s1[x] * s2[y] % int(1e9 + 7) -
                            s1[x] * s1[y] % int(1e9 + 7) * dep[x] %
                                int(1e9 + 7) * 2ll % int(1e9 + 7) +
                            int(1e9 + 7)) %
                           int(1e9 + 7);
    s1[x] = (s1[x] + s1[y]) % int(1e9 + 7),
    s2[x] = (s2[x] + s2[y]) % int(1e9 + 7);
  }
  vec[x].clear();
}
int S[200005];
void SvT(int d) {
  static int p[200005], s[200005];
  int k = 0, tot, Lca = 0, tp = 0;
  long long ret = 0;
  for (int i = d; i <= n; i += d) p[tot = ++k] = po[i];
  for (int i = 1; i <= k; i++) Lca = LCA(p[i], Lca), vt[p[i]] = 1;
  sort(p + 1, p + k + 1, cmp), s[++tp] = Lca;
  for (int i = 1; i <= tot; i++) {
    if (p[i] == Lca) continue;
    int lca = LCA(p[i], s[tp]);
    while (lca != s[tp]) {
      if (dep[s[tp - 1]] < dep[lca]) {
        vec[lca].push_back(s[tp--]);
        if (s[tp] != p[i] && lca != Lca && lca != s[tp]) s[++tp] = lca;
        break;
      }
      vec[s[tp - 1]].push_back(s[tp]), tp--;
    }
    if (s[tp] != p[i]) s[++tp] = p[i];
  }
  while (--tp) vec[s[tp]].push_back(s[tp + 1]);
  dfs1(Lca, 0, ret), s1[Lca] = 0;
  ans = (ans + S[d] * ret % int(1e9 + 7)) % int(1e9 + 7);
}
int main() {
  mul[1] = 1, phi[1] = 1;
  for (int i = 2; i <= 200000; i++) {
    if (!vst[i]) prim[++prim[0]] = i, mul[i] = int(1e9 + 7) - 1, phi[i] = i - 1;
    for (int j = 1; j <= prim[0] && i * prim[j] <= 200000; j++) {
      int x = i * prim[j];
      vst[x] = 1;
      if (i % prim[j] == 0) {
        phi[x] = phi[i] * prim[j];
        break;
      }
      mul[x] = int(1e9 + 7) - mul[i];
      phi[x] = phi[i] * (prim[j] - 1);
    }
  }
  for (int i = 1; i <= 200000; i++) {
    long long iv = 1ll * i * ksm(phi[i], int(1e9 + 7) - 2) % int(1e9 + 7);
    for (int j = 1; i * j <= 200000; j++)
      S[i * j] = (S[i * j] + iv * mul[j] % int(1e9 + 7)) % int(1e9 + 7);
  }
  n = getint();
  for (int i = 1; i <= n; i++) po[a[i] = getint()] = i;
  for (int i = 1; i < n; i++) {
    int u = getint(), v = getint();
    add(u, v), add(v, u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) SvT(i);
  wrt(ans * ksm(n, int(1e9 + 7) - 2) % int(1e9 + 7) *
      ksm(n - 1, int(1e9 + 7) - 2) % int(1e9 + 7) * 2 % int(1e9 + 7)),
      pc('\n');
  fwrite(wb, 1, p2, stdout);
  return 0;
}