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 L = (1 << 19) + 1;
char ibuf[L], *iS, *iT, obuf[L], *oS = obuf, *oT = obuf + L - 1, c, st[55];
int f, tp;
char gc() {
  if (iS == iT) {
    iT = (iS = ibuf) + fread(ibuf, 1, L, stdin);
    return iS == iT ? EOF : *iS++;
  }
  return *iS++;
}
void cbuf() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
void putc(char x) {
  *oS++ = x;
  if (oS == oT) cbuf();
}
void gs(char* s) {
  for (c = gc(); c > 'z' || c < 'a'; c = gc())
    ;
  for (; c >= 'a' && c <= 'z'; c = gc()) *s++ = c;
}
template <class I>
void gi(I& x) {
  for (f = 1, c = gc(); c < '0' || c > '9'; c = gc())
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15);
  x *= f;
}
void ps(char* s) {
  while (*s) putc(*s++);
}
template <class I>
void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) st[++tp] = x % 10 + '0', x /= 10;
  while (tp) putc(st[tp--]);
}
void scan(int l, ...) {
  va_list scan;
  va_start(scan, l);
  while (l) {
    int* w = va_arg(scan, int*);
    gi(*w), l--;
  }
}
};  // namespace io
using io::gi;
using io::gs;
using io::print;
using io::ps;
using io::putc;
using io::scan;
const int N = 2E5 + 5, P = 1E9 + 7, M = 3E4 + 5;
int n, a[N], b[N], eu[N], mu[N], func[N], pri[M], pcnt, inv[N], dfn[N], bel[N],
    fa[N], dfc, sz[N], son[N], dep[N], res, ans, st[N], tp, SUMF[N], SUMG[N],
    F[N];
bool fl[N], col[N];
vector<int> e[N], E[N], ve, id;
int power(int a, int t) {
  int r = 1;
  while (t) {
    if (t & 1) r = (long long)r * a % P;
    a = (long long)a * a % P;
    t >>= 1;
  }
  return r;
}
void dfs(int x) {
  sz[x] = 1, dep[x] = dep[fa[x]] + 1;
  for (auto v : e[x])
    if (v != fa[x]) {
      fa[v] = x, dfs(v), sz[x] += sz[v];
      if (sz[v] > sz[son[x]]) son[x] = v;
    }
}
void dfs(int x, int b) {
  dfn[x] = ++dfc, bel[x] = b;
  if (son[x]) dfs(son[x], b);
  for (auto v : e[x])
    if (v != fa[x] && v != son[x]) dfs(v, v);
}
int lca(int u, int v) {
  while (bel[u] != bel[v])
    dep[bel[u]] > dep[bel[v]] ? u = fa[bel[u]] : v = fa[bel[v]];
  return dep[u] < dep[v] ? u : v;
}
void solve(int x) {
  if (col[x])
    SUMF[x] = F[x], SUMG[x] = (long long)F[x] * dep[x] % P;
  else
    SUMF[x] = SUMG[x] = 0;
  for (auto v : E[x]) {
    solve(v);
    res = (res + (long long)SUMF[x] * SUMG[v] + (long long)SUMF[v] * SUMG[x] -
           (long long)SUMF[x] * SUMF[v] % P * dep[x] * 2) %
          P;
    (SUMF[x] += SUMF[v]) %= P, (SUMG[x] += SUMG[v]) %= P;
  }
}
bool comp(const int& x, const int& y) { return dfn[x] < dfn[y]; }
int calc() {
  res = 0;
  sort(ve.begin(), ve.end(), comp);
  st[++tp] = 1, id.push_back(1), col[1] = ve[0] == 1;
  for (int i = ve[0] == 1, l = ve.size(); i < l; i++) {
    int f = lca(st[tp], ve[i]), last_ = 0;
    while (dep[st[tp]] > dep[f]) {
      if (last_) E[st[tp]].push_back(last_);
      last_ = st[tp], st[tp--] = 0;
    }
    if (st[tp] != f) st[++tp] = f, id.push_back(f);
    if (last_) E[st[tp]].push_back(last_);
    st[++tp] = ve[i], id.push_back(ve[i]);
    col[ve[i]] = true;
  }
  int last_ = 0;
  while (tp) {
    if (last_) E[st[tp]].push_back(last_);
    last_ = st[tp], st[tp--] = 0;
  }
  solve(1);
  for (auto x : id) E[x].clear();
  for (auto x : ve) col[x] = false;
  ve.clear(), id.clear();
  return res;
}
int main() {
  gi(n);
  for (int i = 1; i <= n; i++) gi(a[i]), b[a[i]] = i;
  for (int i = 1, u, v; i < n; i++) {
    gi(u), gi(v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(1);
  dfs(1, 1);
  eu[1] = mu[1] = inv[1] = 1;
  for (int i = 2; i <= n; i++) inv[i] = P - (long long)(P / i) * inv[P % i] % P;
  for (int i = 2; i <= n; i++) {
    if (!fl[i]) {
      pri[++pcnt] = i;
      eu[i] = i - 1;
      mu[i] = -1;
    }
    for (int j = 1; i * pri[j] <= n; j++) {
      fl[i * pri[j]] = true;
      if (i % pri[j] == 0) {
        mu[i * pri[j]] = 0;
        eu[i * pri[j]] = eu[i] * pri[j];
        break;
      }
      mu[i * pri[j]] = -mu[i];
      eu[i * pri[j]] = eu[i] * (pri[j] - 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    int w = (long long)i * inv[eu[i]] % P;
    for (int j = 1; j <= n / i; j++)
      func[i * j] = (func[i * j] + mu[j] * w) % P;
    if (func[i] < 0) func[i] += P;
  }
  for (int d = 1; d <= n; d++) {
    for (int i = d; i <= n; i += d) ve.push_back(b[i]), F[b[i]] = eu[i];
    ans = (ans + (long long)func[d] * calc()) % P;
  }
  if (ans < 0) ans += P;
  ans =
      (long long)(ans << 1) % P * power(n, P - 2) % P * power(n - 1, P - 2) % P;
  print(ans), putc('\n'), io::cbuf();
  return 0;
}