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 iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const long long linf = 1ll << 60;
const double dinf = 1e60;
template <typename T>
inline void scf(T &x) {
  bool f = 0;
  x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) {
  scf(x);
  return scf(y);
}
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) {
  scf(x);
  scf(y);
  return scf(z);
}
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) {
  scf(x);
  scf(y);
  scf(z);
  return scf(w);
}
inline char mygetchar() {
  char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
template <typename T>
inline bool chkmax(T &x, const T &y) {
  return y > x ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmin(T &x, const T &y) {
  return y < x ? x = y, 1 : 0;
}
const int maxn = 2e5 + 100;
const int lgn = 18;
const int mod = 1e9 + 7;
int n, m, ans;
int a[maxn], b[maxn], f[maxn], par[maxn][lgn], dep[maxn], dfn[maxn], End[maxn],
    phi[maxn], x[maxn], y[maxn], inv[maxn];
vector<int> g[maxn], ng[maxn];
bool imp[maxn], isp[maxn];
int pow_mod(int x, int n) {
  int y = 1;
  while (n) {
    if (n & 1) y = 1ll * y * x % mod;
    x = 1ll * x * x % mod;
    n >>= 1;
  }
  return y;
}
void dfs1(int u, int p) {
  dep[u] = dep[p] + 1;
  par[u][0] = p;
  for (int i = 0, _end_ = (lgn - 1); i < _end_; ++i)
    par[u][i + 1] = par[par[u][i]][i];
  dfn[u] = ++m;
  for (int v : g[u])
    if (v != p) dfs1(v, u);
  End[u] = m;
  return;
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v];
  for (int i = 0, _end_ = (lgn); i < _end_; ++i)
    if ((d >> i) & 1) u = par[u][i];
  if (u == v) return u;
  for (int i = (lgn)-1; i >= 0; --i)
    if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
  return par[u][0];
}
void merge(int u, int phi, int dep) {
  (ans += 1ll * x[u] * phi % mod * (dep - 2 * ::dep[u]) % mod) %= mod;
  (ans += 1ll * y[u] * phi % mod) %= mod;
  return;
}
void ins(int u, int phi, int dep) {
  (x[u] += phi) %= mod;
  (y[u] += 1ll * phi * dep % mod) %= mod;
  return;
}
void merge(int u, int rt) {
  if (imp[u]) merge(rt, phi[a[u]], dep[u]);
  for (int v : ng[u]) merge(v, rt);
  return;
}
void ins(int u, int rt) {
  if (imp[u]) ins(rt, phi[a[u]], dep[u]);
  for (int v : ng[u]) ins(v, rt);
  return;
}
int dfs(int u) {
  int hs = 0, son = 0, siz = 1;
  for (int v : ng[u]) {
    int tmp = dfs(v);
    siz += tmp;
    if (chkmax(hs, tmp)) son = v;
  }
  if (!son) {
    if (imp[u]) {
      x[u] = phi[a[u]];
      y[u] = 1ll * x[u] * dep[u] % mod;
    }
    return siz;
  }
  x[u] = x[son];
  y[u] = y[son];
  if (imp[u]) merge(u, phi[a[u]], dep[u]), ins(u, phi[a[u]], dep[u]);
  for (int v : ng[u])
    if (v != son) merge(v, u), ins(v, u);
  return siz;
}
int main() {
  scf(n);
  for (int i = (1), _end_ = (n); i <= _end_; ++i) scf(a[i]), b[a[i]] = i;
  for (int i = (2), _end_ = (n); i <= _end_; ++i) isp[i] = 1;
  phi[1] = 1;
  static vector<int> pme;
  for (int i = (2), _end_ = (n); i <= _end_; ++i) {
    if (isp[i]) pme.push_back(i), phi[i] = i - 1;
    for (int p : pme) {
      if (p * i > n) break;
      isp[p * i] = 0;
      if (i % p == 0) {
        phi[i * p] = phi[i] * p;
        break;
      }
      phi[i * p] = phi[i] * phi[p];
    }
  }
  for (int i = (1), _end_ = (n); i <= _end_; ++i)
    inv[i] = pow_mod(phi[i], mod - 2);
  for (int i = 0, _end_ = (n - 1); i < _end_; ++i) {
    int u, v;
    scf(u, v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs1(1, 0);
  auto cmp = [&](int a, int b) { return dfn[a] < dfn[b]; };
  for (int d = (1), _end_ = (n); d <= _end_; ++d) {
    static vector<int> tmp, all, stk;
    tmp.clear();
    stk.clear();
    for (int i = d; i <= n; i += d) tmp.push_back(b[i]);
    sort(tmp.begin(), tmp.end(), cmp);
    all = tmp;
    for (int i = 0, _end_ = ((int)tmp.size() - 1); i < _end_; ++i)
      all.push_back(lca(tmp[i], tmp[i + 1]));
    sort(all.begin(), all.end(), cmp);
    all.resize(unique(all.begin(), all.end()) - all.begin());
    for (int u : all) ng[u].clear(), imp[u] = 0, x[u] = y[u] = 0;
    for (int u : tmp) imp[u] = 1;
    int root;
    for (int u : all) {
      while ((int)stk.size() &&
             !(dfn[stk.back()] <= dfn[u] && dfn[u] <= End[stk.back()]))
        stk.pop_back();
      if (!(int)stk.size())
        root = u;
      else
        ng[stk.back()].push_back(u);
      stk.push_back(u);
    }
    ans = 0;
    dfs(root);
    f[d] = (ans + ans) % mod;
  }
  for (int d = (n), _end_ = (1); d >= _end_; --d)
    for (int i = d + d; i <= n; i += d) (f[d] -= f[i]) %= mod;
  int ans = 0;
  for (int d = (1), _end_ = (n); d <= _end_; ++d) {
    ((f[d] %= mod) += mod) %= mod;
    (ans += 1ll * f[d] * d % mod * inv[d] % mod) %= mod;
  }
  printf("%d\n", 1ll * ans * pow_mod(1ll * n * (n - 1) % mod, mod - 2) % mod);
  return 0;
}