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;
template <class T>
void rd(T &x) {
  static char c;
  static int f;
  x = 0;
  f = 1;
  while (c = getchar(), c < 48)
    if (c == '-') f = -1;
  do x = (x * 10) + (c & 15);
  while (c = getchar(), c > 47);
  x *= f;
}
template <class T>
void prin(T x) {
  if (x < 0)
    x = -x, putchar('-');
  else if (!x) {
    putchar('0');
    return;
  }
  static int tp, stk[100];
  while (x) stk[tp++] = x % 10, x /= 10;
  while (tp) putchar(stk[--tp] ^ 48);
}
template <class T>
void ptn(T x) {
  prin(x);
  putchar('\n');
}
template <class T>
void ptk(T x) {
  prin(x);
  putchar(' ');
}
template <class T>
void Min(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
void Max(T &a, T b) {
  if (a < b) a = b;
}
const int N = (int)2e5 + 5, mod = (int)1e9 + 7;
int head[N], tp[N], sz[N], son[N], par[N], dep[N], dfn[N], post[N], tot_edge;
pair<int, int> G[N << 1];
int n, a[N], pr[N], pr_pow[N], phi[N], inv[N], prime[N >> 1], prime_cnt, mu[N];
void init() {
  phi[1] = mu[1] = inv[1] = 1;
  ++n;
  for (int i = (2), _t = (n); i < _t; ++i) {
    inv[i] = (long long)(mod - mod / i) * inv[mod % i] % mod;
    if (!pr[i]) pr[i] = pr_pow[i] = prime[prime_cnt++] = i;
    if (pr_pow[i] == i)
      phi[i] = i - i / pr[i], mu[i] = -(pr[i] == i);
    else
      phi[i] = phi[i / pr_pow[i]] * phi[pr_pow[i]],
      mu[i] = mu[i / pr_pow[i]] * mu[pr_pow[i]];
    for (int j = 0, p, t;
         j < prime_cnt && (p = prime[j]) <= pr[i] && (t = i * p) < n; ++j) {
      pr[t] = p;
      pr_pow[t] = pr[i] == p ? p * pr_pow[i] : p;
    }
  }
  --n;
}
void pre_dfs(int x) {
  sz[x] = 1;
  for (int i = head[x]; i; i = G[i].second) {
    int y = G[i].first;
    if (y == par[x]) continue;
    par[y] = x;
    dep[y] = dep[x] + 1;
    pre_dfs(y);
    sz[x] += sz[y];
    if (sz[y] > sz[son[x]]) son[x] = y;
  }
}
void rdfs(int x) {
  static int dfn_clock;
  dfn[x] = ++dfn_clock;
  if (son[x]) {
    tp[son[x]] = tp[x];
    rdfs(son[x]);
  }
  for (int i = head[x]; i; i = G[i].second) {
    int y = G[i].first;
    if (y == par[x] || y == son[x]) continue;
    rdfs(tp[y] = y);
  }
  post[x] = dfn_clock;
}
int LCA(int x, int y) {
  while (tp[x] != tp[y]) {
    if (dep[tp[x]] > dep[tp[y]])
      x = par[tp[x]];
    else
      y = par[tp[y]];
  }
  if (dep[x] < dep[y]) return x;
  return y;
}
void add_mod(int &a, int b) {
  if ((a += b) >= mod) a -= mod;
}
void del_mod(int &a, int b) {
  if ((a -= b) < 0) a += mod;
}
int f[N], Mp[N], que[N], que_cnt, sum_phi, sum[N], lst[N], ans;
pair<int, int> E[N];
bool mark[N], flag[N];
bool cmp(const int a, const int &b) { return dfn[a] < dfn[b]; }
void dfs(int x) {
  if (flag[x])
    sum[x] = phi[a[x]];
  else
    sum[x] = 0;
  for (int i = lst[x]; i; i = E[i].second) {
    int y = E[i].first;
    dfs(y);
    ans = (ans +
           (sum_phi - sum[y]) * (long long)sum[y] % mod * (dep[y] - dep[x])) %
          mod;
    add_mod(sum[x], sum[y]);
  }
}
int calc(int step) {
  sum_phi = que_cnt = ans = 0;
  for (int i = step; i <= n; i += step) {
    que[que_cnt++] = Mp[i];
    flag[Mp[i]] = mark[Mp[i]] = true;
    add_mod(sum_phi, phi[i]);
  }
  sort(que, que + que_cnt, cmp);
  for (int i = (1), _t = (que_cnt); i < _t; ++i) {
    int anc = LCA(que[i], que[i - 1]);
    if (!mark[anc]) {
      que[que_cnt++] = anc;
      mark[anc] = true;
    }
  }
  sort(que, que + que_cnt, cmp);
  static int stk[N], tp;
  lst[stk[tp = 0] = que[0]] = 0;
  for (int i = (1), _t = (que_cnt); i < _t; ++i) {
    while (tp && dfn[que[i]] > post[stk[tp]]) --tp;
    E[i] = pair<int, int>(que[i], lst[stk[tp]]);
    lst[stk[tp]] = i;
    stk[++tp] = que[i];
    lst[que[i]] = 0;
  }
  dfs(que[0]);
  for (int i = (0), _t = (que_cnt); i < _t; ++i)
    flag[que[i]] = mark[que[i]] = false;
  return ans;
}
int main() {
  rd(n);
  for (int i = (1), _t = (n + 1); i < _t; ++i) rd(a[i]), Mp[a[i]] = i;
  init();
  for (int x, y, i = 1; i < n; ++i) {
    rd(x), rd(y);
    G[++tot_edge] = pair<int, int>(y, head[x]);
    head[x] = tot_edge;
    G[++tot_edge] = pair<int, int>(x, head[y]);
    head[y] = tot_edge;
  }
  pre_dfs(1);
  rdfs(tp[1] = 1);
  int ans = 0;
  for (int i = (n + 1) - 1, _s = (1); i >= _s; --i) {
    f[i] = calc(i);
    for (int j = i << 1; j <= n; j += i) del_mod(f[i], f[j]);
    ans = (ans + (long long)i * inv[phi[i]] % mod * f[i]) % mod;
  }
  add_mod(ans, ans);
  ans = (long long)ans * inv[n] % mod * inv[n - 1] % mod;
  ptn(ans);
  return 0;
}