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>
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
using namespace std;
const int N = 6e5 + 10, mod = 1e9 + 7, inf = 0x3f3f3f3f;
int tot, head[N], ver[N << 1], Next[N << 1];
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a >= b ? a - b : a - b + mod; }
inline int mul(int a, int b) { return 1ll * a * b % mod; }
inline int power(int a, int b) {
  int res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
  }
  return res;
}
inline void adde(int x, int y) {
  ver[++tot] = y;
  Next[tot] = head[x];
  head[x] = tot;
}
int dfn[N], dfnnum;
inline bool cmp(int a, int b) { return dfn[a] < dfn[b]; }
namespace Lca {
int euler[N << 1][21], pos[N], cnt, dep[N], logval[N << 1];
inline void dfs(int x, int f) {
  dfn[x] = ++dfnnum;
  euler[++cnt][0] = x;
  pos[x] = cnt;
  for (int i = head[x]; i; i = Next[i]) {
    int y = ver[i];
    if (y == f) continue;
    dep[y] = dep[x] + 1;
    dfs(y, x);
    euler[++cnt][0] = x;
  }
}
inline int calc(int a, int b) { return dep[a] < dep[b] ? a : b; }
inline void prework(void) {
  dep[1] = 1;
  dfs(1, 0);
  logval[0] = -1;
  for (int i = 1; i <= cnt; i++) logval[i] = logval[i >> 1] + 1;
  for (int j = 1; (1 << j) <= cnt; j++)
    for (int i = 1; i + (1 << j) <= cnt; i++)
      euler[i][j] = calc(euler[i][j - 1], euler[i + (1 << (j - 1))][j - 1]);
}
inline int lca(int u, int v) {
  if (pos[u] > pos[v]) swap(u, v);
  int a = pos[u], b = pos[v], k = logval[b - a + 1];
  return calc(euler[a][k], euler[b - (1 << k) + 1][k]);
  ;
}
}  // namespace Lca
namespace VT {
int Stack[N], top;
inline void init(void) {
  top = 0;
  tot = 0;
}
inline void insert(int now) {
  int l = Lca::lca(now, Stack[top]);
  while (true) {
    if (Lca::dep[l] >= Lca::dep[Stack[top - 1]]) {
      if (l != Stack[top]) {
        adde(l, Stack[top]);
        if (l != Stack[top - 1])
          Stack[top] = l;
        else
          top--;
      }
      break;
    } else {
      adde(Stack[top - 1], Stack[top]);
      top--;
    }
  }
  Stack[++top] = now;
}
}  // namespace VT
namespace sieve {
int cnt, p[N], phi[N], miu[N];
bool vis[N];
inline void prework(int n) {
  phi[1] = miu[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) p[++cnt] = i, phi[i] = i - 1, miu[i] = -1;
    for (int j = 1; j <= cnt; j++) {
      if (p[j] > n / i) break;
      vis[i * p[j]] = true;
      if (i % p[j] == 0) {
        phi[i * p[j]] = phi[i] * p[j];
        break;
      }
      miu[i * p[j]] = -miu[i];
      phi[i * p[j]] = phi[i] * phi[p[j]];
    }
  }
}
}  // namespace sieve
using Lca::dep;
using sieve::miu;
using sieve::phi;
int n, a[N], rev[N], ans, dp[N];
bool flag[N];
inline void solve(int x, int fa) {
  dp[x] = 0;
  if (flag[x])
    ans = add(ans, mul(2, mul(dep[x], mul(phi[a[x]], phi[a[x]])))),
    dp[x] = phi[a[x]];
  for (int i = head[x]; i; i = Next[i]) {
    int y = ver[i];
    if (y == fa) continue;
    solve(y, x);
    ans = add(ans, mul(4, mul(dp[x], mul(dp[y], dep[x]))));
    dp[x] = add(dp[x], dp[y]);
    dp[y] = 0;
  }
  head[x] = 0;
}
int f[N], g[N], vec[N], ret;
int main() {
  sieve::prework(2e5);
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), rev[a[i]] = i;
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    adde(x, y);
    adde(y, x);
  }
  Lca::prework();
  memset(head, 0, sizeof head);
  for (int e = 1; e <= n; e++) {
    VT::init();
    if (e > n / 2) break;
    int num = 0, sum = 0;
    ans = 0;
    ret = 0;
    for (int i = e; i <= n; i += e) {
      flag[rev[i]] = true;
      sum = add(sum, mul(phi[i], dep[rev[i]]));
      num = add(num, phi[i]);
      vec[++ret] = rev[i];
    }
    sort(vec + 1, vec + ret + 1, cmp);
    VT::top = 1;
    VT::Stack[1] = 1;
    for (int i = 1; i <= ret; i++) VT::insert(vec[i]);
    while (VT::top > 1)
      adde(VT::Stack[VT::top - 1], VT::Stack[VT::top]), VT::top--;
    sum = mul(sum, num);
    solve(1, 1);
    f[e] = sub(mul(2, sum), ans);
    for (int i = e; i <= n; i += e) flag[rev[i]] = false;
  }
  for (int i = 1; i <= n; i++) miu[i] = add(miu[i], mod);
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i) g[i] = add(g[i], mul(f[j], miu[j / i]));
  int res = 0;
  ans = 0;
  for (int i = 1; i <= n; i++)
    ans = add(ans, mul(i, mul(g[i], power(phi[i], mod - 2))));
  ans = mul(ans, power(n, mod - 2));
  ans = mul(ans, power(n - 1, mod - 2));
  printf("%d\n", ans);
  return 0;
}