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 = 200005, mod = 1e9 + 7;
char buf[1 << 20], *p1, *p2;
inline int _R() {
  int d = 0;
  bool ty = 1;
  char t;
  while (t = ((p1 == p2 &&
               (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2))
                  ? 0
                  : *p1++),
         (t < '0' || t > '9') && t != '-')
    ;
  t == '-' ? (ty = 0) : (d = t - '0');
  while (t = ((p1 == p2 &&
               (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2))
                  ? 0
                  : *p1++),
         t >= '0' && t <= '9')
    d = (d << 3) + (d << 1) + t - '0';
  return ty ? d : -d;
}
inline int add(int a, int b) {
  a += b;
  return a >= mod ? a - mod : a;
}
inline int sub(int a, int b) {
  a -= b;
  return a < 0 ? a + mod : a;
}
inline int mul(int a, int b) { return 1LL * a * b % mod; }
inline int ksm(int a, int b) {
  int r;
  for (r = 1; b; b >>= 1, a = mul(a, a))
    if (b & 1) r = mul(r, a);
  return r;
}
inline void inc(int& a, int b) { a = add(a, b); }
inline void dec(int& a, int b) { a = sub(a, b); }
int n, a[N], b[N];
int phi[N], pri[N], vis[N], mu[N];
void euler() {
  phi[1] = mu[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) pri[++pri[0]] = i, phi[i] = i - 1, mu[i] = mod - 1;
    for (int j = 1; i * pri[j] <= n && j <= pri[0]; j++) {
      int k = i * pri[j];
      vis[k] = 1;
      if (i % pri[j] == 0) {
        phi[k] = phi[i] * pri[j];
        mu[k] = 0;
        break;
      } else
        mu[k] = mod - mu[i], phi[k] = phi[i] * (pri[j] - 1);
    }
  }
}
int Tote, Last[N], End[N << 1], Next[N << 1];
void ADDE() {
  int x = _R(), y = _R();
  End[++Tote] = y, Next[Tote] = Last[x], Last[x] = Tote;
  End[++Tote] = x, Next[Tote] = Last[y], Last[y] = Tote;
}
int vtt, dfn[N], top[N], fa[N], dep[N], hson[N];
int dfs_init(int x) {
  dfn[x] = ++vtt;
  dep[x] = dep[fa[x]] + 1;
  int i, u, tmp, sz = 1, maxx = 0;
  for (i = Last[x]; i; i = Next[i])
    if (u = End[i], u != fa[x])
      if (fa[u] = x, tmp = dfs_init(u), tmp > maxx) maxx = tmp, hson[x] = u;
  return sz;
}
void dfs_make(int x) {
  if (hson[x]) top[hson[x]] = top[x], dfs_make(hson[x]);
  for (int i = Last[x], u; i; i = Next[i])
    if (u = End[i], u != fa[x] && u != hson[x]) dfs_make(top[u] = u);
}
int lca(int x, int y) {
  while (top[x] != top[y])
    if (dep[top[x]] > dep[top[y]])
      x = fa[top[x]];
    else
      y = fa[top[y]];
  return dep[x] < dep[y] ? x : y;
}
namespace SSS {
int g[N], s[N];
bool cmp(int a, int b) { return dfn[a] < dfn[b]; }
int Tote, Last[N], End[N], Next[N];
void ADDE(int x, int y) {
  End[++Tote] = y, Next[Tote] = Last[x], Last[x] = Tote;
}
int ans;
bool vis[N];
int dp1(int x) {
  int i, u, sum = 0, tt = 0, tmp;
  if (vis[x]) sum = phi[a[x]];
  for (i = Last[x]; i; i = Next[i]) {
    u = End[i];
    tmp = dp1(u);
    inc(tt, mul(sum, tmp));
    inc(sum, tmp);
  }
  dec(ans, mul(add(dep[x], dep[x]), add(tt, tt)));
  return sum;
}
void dp2(int x, int d) {
  if (vis[x]) inc(ans, mul(2, mul(mul(phi[a[x]], dep[x]), sub(d, phi[a[x]]))));
  for (int i = Last[x]; i; i = Next[i]) dp2(End[i], d);
  Last[x] = vis[x] = 0;
}
int solve(int d) {
  int i, t, top = 0, tot = 0;
  Tote = 0;
  for (i = d; i <= n; i += d) g[++tot] = b[i], vis[b[i]] = 1;
  if (tot <= 1) return 0;
  sort(g + 1, g + 1 + tot, cmp);
  s[++top] = 1;
  if (g[1] != 1) s[++top] = g[1];
  for (i = 2; i <= tot; i++) {
    t = lca(g[i - 1], g[i]);
    while (top > 1 && dep[s[top - 1]] >= dep[t]) {
      ADDE(s[top - 1], s[top]);
      top--;
    }
    if (s[top] != t) ADDE(t, s[top]), s[top] = t;
    s[++top] = g[i];
  }
  while (top > 1) ADDE(s[top - 1], s[top]), top--;
  ans = 0;
  dp2(1, dp1(1));
  return ans;
}
}  // namespace SSS
int f[N];
int main() {
  int i, j;
  n = _R(), euler();
  for (i = 1; i <= n; i++) a[i] = _R(), b[a[i]] = i;
  for (i = 1; i < n; i++) ADDE();
  dfs_init(1);
  dfs_make(top[1] = 1);
  for (i = 1; i <= n; i++) f[i] = SSS ::solve(i);
  int ans = 0;
  for (i = 1; i <= n; i++) {
    int tmp = 0;
    for (j = i; j <= n; j += i) inc(tmp, mul(f[j], mu[j / i]));
    inc(ans, mul(tmp, mul(i, ksm(phi[i], mod - 2))));
  }
  printf("%d\n", mul(ans, ksm(mul(n, n - 1), mod - 2)));
}