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;
namespace io {
const int SIZE = 1 << 21 | 1;
char ibuf[SIZE], *iS, *iT, c;
template <class I>
inline void gi(I &x) {
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    ;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
}
}  // namespace io
using io ::gi;
const int MaxN(200003);
const int Mod(1e9 + 7);
bool p[MaxN], Vis[MaxN];
int K, root, n, cnt, ans, Index;
int Deep[MaxN], h[MaxN], Size[MaxN];
int a[MaxN], Pr[MaxN], phi[MaxN], s[MaxN];
int dfn[MaxN], mu[MaxN], F[MaxN], fa[21][MaxN];
vector<int> G[MaxN], nG[MaxN];
inline void upd(int &x, int y) { (x += y) >= Mod ? x -= Mod : x; }
inline void add(int u, int v) {
  nG[u].push_back(v);
  nG[v].push_back(u);
}
int fexp(int x, int k) {
  int res = 1;
  for (; k; k >>= 1, x = (unsigned long long)x * x % Mod)
    if (k & 1) res = (unsigned long long)res * x % Mod;
  return res;
}
void getprime(int n) {
  mu[1] = phi[1] = 1;
  for (int i = 2, tot = 0; i <= n; i++) {
    if (!p[i]) {
      Pr[++tot] = i;
      phi[i] = i - 1, mu[i] = Mod - 1;
    }
    for (int j = 1; j <= tot && Pr[j] * i <= n; j++) {
      p[Pr[j] * i] = 1;
      if (i % Pr[j]) {
        phi[i * Pr[j]] = phi[i] * phi[Pr[j]];
        mu[i * Pr[j]] = Mod - mu[i];
      } else {
        phi[i * Pr[j]] = phi[i] * Pr[j];
        break;
      }
    }
  }
}
void dfs(int u) {
  dfn[u] = ++Index;
  Deep[u] = Deep[fa[0][u]] + 1;
  for (auto v : G[u])
    if (v != fa[0][u]) fa[0][v] = u, dfs(v);
}
void Init() {
  dfs(1);
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i <= n; i++) fa[j][i] = fa[j - 1][fa[j - 1][i]];
}
int lca(int u, int v) {
  if (Deep[u] < Deep[v]) swap(u, v);
  for (int j = 19; ~j; j--)
    if (Deep[fa[j][u]] >= Deep[v]) u = fa[j][u];
  if (u == v) return u;
  for (int j = 19; ~j; j--)
    if (fa[j][u] ^ fa[j][v]) u = fa[j][u], v = fa[j][v];
  return fa[0][u];
}
void Build() {
  int top;
  static int S[MaxN];
  sort(h + 1, h + 1 + K, [](int x, int y) { return dfn[x] < dfn[y]; });
  S[top = 1] = h[1];
  for (int i = 2; i <= K; i++) {
    int f = lca(h[i], S[top]);
    while (top > 1 && dfn[f] <= dfn[S[top - 1]]) add(S[top], S[top - 1]), --top;
    if (f != S[top]) add(f, S[top]), S[top] = f;
    S[++top] = h[i];
  }
  while (top > 1) add(S[top], S[top - 1]), --top;
  root = S[top];
}
void dp(int u, int f) {
  Size[u] = Vis[u] ? phi[a[u]] : 0;
  for (auto v : nG[u])
    if (v != f) {
      dp(v, u);
      upd(cnt, (unsigned long long)Size[u] * Size[v] % Mod * Deep[u] % Mod);
      upd(Size[u], Size[v]);
    }
  nG[u].clear();
}
int solve(int d) {
  K = 0;
  for (int i = d; i <= n; i += d) Vis[h[++K] = s[i]] = true;
  cnt = 0, Build(), dp(root, 0);
  int res = 0, tmp = 0;
  for (int i = 1; i <= K; i++) upd(res, phi[a[h[i]]]);
  for (int i = 1; i <= K; i++) {
    int w = phi[a[h[i]]];
    upd(tmp, (unsigned long long)w * (res - w + Mod) % Mod * Deep[h[i]] % Mod);
    Vis[h[i]] = false;
  }
  return tmp = (tmp - 2ull * cnt % Mod + Mod) % Mod;
}
int main() {
  gi(n);
  getprime(n);
  for (int i = 1; i <= n; i++) gi(a[i]), s[a[i]] = i;
  for (int i = 1, u, v; i < n; i++) {
    gi(u), gi(v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  Init();
  for (int i = 1; i <= n; i++) F[i] = solve(i);
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = 1; i * j <= n; j++)
      upd(tmp, (unsigned long long)mu[j] * F[i * j] % Mod);
    upd(ans, (unsigned long long)tmp * i % Mod * fexp(phi[i], Mod - 2) % Mod);
  }
  ans = 2ull * ans % Mod * fexp(n, Mod - 2) % Mod * fexp(n - 1, Mod - 2) % Mod;
  printf("%d\n", ans);
  return 0;
}