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>.
#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x7fffffffffffffff;
const double eps = 1e-10;
unsigned int seed = 19260817;
const unsigned int _RAND_MAX_ = 4294967295u;
__inline__ __attribute__((always_inline)) unsigned int Rand() {
  return seed = seed * 998244353u + 1000000007u;
}
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {
  return a > 0 ? a : -a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b) {
  return a < b ? b : a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b) {
  return a < b ? a : b;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {
  (a > b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) bool _cmp(const _Tp &a,
                                                    const _Tp &b) {
  return abs(a - b) <= eps;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void read(_Tp &x) {
  register char ch(getchar());
  bool f(false);
  while (ch < 48 || ch > 57) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (ch >= 48 && ch <= 57)
    x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  if (f) x = -x;
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
__inline__ __attribute__((always_inline)) int read_str(char *s) {
  register char ch(getchar());
  while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
  register char *tar = s;
  *tar = ch, ch = getchar();
  while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
const int N = 200005;
const int mod = 1000000007;
struct edge {
  int v, nxt;
} c[N << 1];
struct Edge {
  int v, nxt, w;
} e[N << 1];
int head[N], _cnt;
__inline__ __attribute__((always_inline)) void _add(const int &u, const int &v,
                                                    const int &w) {
  e[++_cnt] = (Edge){v, head[u], w}, head[u] = _cnt;
}
int front[N], cnt;
__inline__ __attribute__((always_inline)) void add_(const int &u,
                                                    const int &v) {
  c[++cnt] = (edge){v, front[u]}, front[u] = cnt;
}
bool pr[N];
int a[N], pos;
int mu[N], phi[N];
int inv[N];
int f[N];
__inline__ __attribute__((always_inline)) void add(int &a, const int &b) {
  (a += b) >= mod && (a -= mod);
}
__inline__ __attribute__((always_inline)) void sub(int &a, const int &b) {
  (a -= b) < 0 && (a += mod);
}
void init(int n) {
  mu[1] = phi[1] = 1;
  inv[1] = 1, inv[0] = 1;
  for (int i = 2; i <= n; ++i) {
    inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
    if (!pr[i]) {
      a[++pos] = i;
      mu[i] = -1;
      phi[i] = i - 1;
    }
    for (int j = 1; j <= pos && i * a[j] <= n; ++j) {
      pr[i * a[j]] = 1;
      if (!(i % a[j])) {
        mu[i * a[j]] = 0;
        phi[i * a[j]] = a[j] * phi[i];
        break;
      }
      mu[i * a[j]] = -mu[i];
      phi[i * a[j]] = phi[i] * phi[a[j]];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i, k = 1; j <= n; j += i, ++k) {
      if (mu[k] > 0)
        add(f[j], 1ll * i * inv[phi[i]] % mod);
      else if (mu[k] < 0)
        sub(f[j], 1ll * i * inv[phi[i]] % mod);
    }
  }
}
int id[N];
int dep[N], siz[N], son[N], Fa[N];
int top[N], dfn[N], _id;
void dfs1(int x, int fa) {
  Fa[x] = fa, siz[x] = 1;
  dep[x] = dep[fa] + 1;
  for (int i = front[x]; i; i = c[i].nxt) {
    if (c[i].v != fa) {
      dfs1(c[i].v, x);
      siz[x] += siz[c[i].v];
      if (siz[c[i].v] > siz[son[x]]) {
        son[x] = c[i].v;
      }
    }
  }
}
void dfs2(int x, int topf) {
  top[x] = topf;
  dfn[x] = ++_id;
  if (!son[x]) return;
  dfs2(son[x], topf);
  for (int i = front[x]; i; i = c[i].nxt) {
    if (!top[c[i].v]) {
      dfs2(c[i].v, c[i].v);
    }
  }
}
int lca(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] > dep[top[y]])
      x = Fa[top[x]];
    else
      y = Fa[top[y]];
  }
  return dep[x] < dep[y] ? x : y;
}
__inline__ __attribute__((always_inline)) bool cmp(const int &a, const int &b) {
  return dfn[a] < dfn[b];
}
int st[N], _top;
int tmp[N], len;
void insert(int x) {
  if (!_top ||
      (dfn[x] >= dfn[st[_top]] && dfn[x] < dfn[st[_top]] + siz[st[_top]])) {
    st[++_top] = x;
    tmp[++len] = x;
    return;
  }
  int l = lca(x, st[_top]);
  while (_top > 1 && dfn[st[_top - 1]] >= dfn[l]) {
    _add(st[_top - 1], st[_top], dep[st[_top]] - dep[st[_top - 1]]);
    --_top;
  }
  if (st[_top] != l) {
    _add(l, st[_top], dep[st[_top]] - dep[l]);
    st[_top] = l;
    tmp[++len] = l;
  }
  st[++_top] = x;
  tmp[++len] = x;
}
int v[N];
int t[N];
bool mark[N];
struct node {
  int dis_sum, sum, ans;
};
node dfs(int x) {
  node cur = (node){0, 0, 0}, tmp;
  if (mark[x]) {
    cur.sum = v[x];
  }
  for (int i = head[x]; i; i = e[i].nxt) {
    tmp = dfs(e[i].v);
    add(tmp.dis_sum, 1ll * tmp.sum * e[i].w % mod);
    add(cur.ans, 1ll * cur.dis_sum * tmp.sum % mod);
    add(cur.ans, 1ll * cur.sum * tmp.dis_sum % mod);
    add(cur.ans, tmp.ans);
    add(cur.dis_sum, tmp.dis_sum);
    add(cur.sum, tmp.sum);
  }
  return cur;
}
int main() {
  int n;
  read(n);
  init(n);
  int x, y;
  for (int i = 1; i <= n; ++i) {
    read(x);
    id[x] = i;
  }
  for (int i = 1; i < n; ++i) {
    read(x, y);
    add_(x, y), add_(y, x);
  }
  dfs1(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= n; ++i) v[id[i]] = phi[i];
  int ans = 0;
  for (int T = 1; T <= n; ++T) {
    int _pos = 0;
    _top = 0;
    _cnt = 0;
    for (int i = T; i <= n; i += T) {
      t[++_pos] = id[i];
    }
    std::sort(t + 1, t + _pos + 1, cmp);
    for (int i = 1; i <= _pos; ++i) {
      mark[t[i]] = 1;
      insert(t[i]);
    }
    while (_top > 1)
      _add(st[_top - 1], st[_top], dep[st[_top]] - dep[st[_top - 1]]), --_top;
    int minn = inf, id_ = 0;
    for (int i = 1; i <= len; ++i) {
      if (dfn[tmp[i]] < minn) {
        minn = dfn[tmp[i]];
        id_ = tmp[i];
      }
    }
    add(ans, 1ll * dfs(id_).ans * f[T] % mod);
    while (len) {
      head[tmp[len--]] = 0;
    }
    while (_pos) {
      mark[t[_pos--]] = 0;
    }
  }
  ans = 2ll * ans * inv[n] % mod * inv[n - 1] % mod;
  printf("%d\n", ans);
  return 0;
}
