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 maxn = 2E5 + 5;
const long long mo = 1000000007;
int n, O, Max, cnt, tot, Cnt, phi[maxn], A[maxn], Fac[maxn], mu[maxn],
    pri[maxn], inq[maxn], dis[maxn], Inv[maxn], siz[maxn], sumphi[maxn],
    vis[maxn];
bool not_pri[maxn], Huge[maxn];
long long Ans;
queue<int> Q;
stack<int> stk;
vector<int> v[maxn], d[maxn], c[maxn];
inline int getint() {
  char ch = getchar();
  int ret = 0;
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return ret;
}
int ksm(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1) {
    if (y & 1) ret = (1LL * (ret) * (x) % mo);
    x = (1LL * (x) * (x) % mo);
  }
  return ret;
}
inline void Clear() {
  while (!stk.empty()) sumphi[stk.top()] = 0, stk.pop();
}
inline void Insert(int x) {
  int y = A[x];
  for (int i = 0; i < d[y].size(); i++) {
    int now = d[y][i];
    sumphi[now] =
        ((sumphi[now]) + (phi[y]) < mo ? (sumphi[now]) + (phi[y])
                                       : (sumphi[now]) + (phi[y]) - mo);
    if (vis[now] != cnt) vis[now] = cnt, stk.push(now);
  }
}
inline void Dfs2(int x, int tot, int from) {
  int ma = 0;
  siz[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int to = v[x][i];
    if (to == from || Huge[to]) continue;
    Dfs2(to, tot, x);
    siz[x] += siz[to];
    ma = ((ma) > (siz[to]) ? (ma) : (siz[to]));
  }
  ma = ((ma) > (tot - siz[x]) ? (ma) : (tot - siz[x]));
  if (ma < Max) Max = ma, O = x;
}
inline void BFS1(int x) {
  dis[x] = 1;
  inq[x] = ++Cnt;
  Q.push(x);
  while (!Q.empty()) {
    int k = Q.front(), y = A[k];
    Q.pop();
    long long sum = 0;
    for (int i = 0; i < d[y].size(); i++) {
      sum += 1LL * c[y][i] * sumphi[d[y][i]];
    }
    sum %= mo;
    Ans += (1LL * (sum) * ((1LL * (phi[y]) * (dis[k]) % mo)) % mo);
    for (int i = 0; i < v[k].size(); i++) {
      int to = v[k][i];
      if (inq[to] == Cnt || Huge[to]) continue;
      inq[to] = Cnt;
      dis[to] = dis[k] + 1;
      Q.push(to);
    }
  }
  Ans %= mo;
}
inline int BFS2(int x) {
  int ret = 0;
  Q.push(x);
  inq[x] = ++Cnt;
  while (!Q.empty()) {
    int k = Q.front();
    Q.pop();
    ++ret;
    Insert(k);
    for (int i = 0; i < v[k].size(); i++) {
      int to = v[k][i];
      if (inq[to] == Cnt || Huge[to]) continue;
      inq[to] = Cnt;
      Q.push(to);
    }
  }
  return ret;
}
inline void Dfs1(int x, int tot) {
  Max = maxn;
  Dfs2(x, tot, 0);
  int o = O;
  Huge[o] = 1;
  ++cnt;
  Insert(o);
  for (int i = 0; i < v[o].size(); i++) {
    int to = v[o][i];
    if (Huge[to]) continue;
    BFS1(to);
    BFS2(to);
  }
  Clear();
  ++cnt;
  for (int i = v[o].size() - 1; i >= 0; i--) {
    int to = v[o][i];
    if (Huge[to]) continue;
    BFS1(to);
    siz[to] = BFS2(to);
  }
  Clear();
  for (int i = 0; i < v[o].size(); i++) {
    int to = v[o][i];
    if (Huge[to]) continue;
    Dfs1(to, siz[to]);
  }
}
void Pre_Work() {
  n = getint();
  Fac[0] = 1;
  for (int i = 1; i <= n; i++) Fac[i] = (1LL * (Fac[i - 1]) * (i) % mo);
  Inv[n] = ksm(Fac[n], mo - 2);
  for (int i = n - 1; i; i--) Inv[i] = (1LL * (Inv[i + 1]) * (i + 1) % mo);
  for (int i = n; i; i--) Inv[i] = (1LL * (Inv[i]) * (Fac[i - 1]) % mo);
  for (int i = 1; i <= n; i++) A[i] = getint();
  for (int i = 1; i < n; i++) {
    int x = getint(), y = getint();
    v[x].push_back(y);
    v[y].push_back(x);
  }
  phi[1] = mu[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!not_pri[i]) pri[++tot] = i, phi[i] = i - 1, mu[i] = -1;
    for (int j = 1; j <= tot; j++) {
      int Nex = i * pri[j];
      if (Nex > n) break;
      not_pri[Nex] = 1;
      if (i % pri[j] == 0) {
        phi[Nex] = phi[i] * pri[j];
        mu[Nex] = 0;
        break;
      }
      mu[Nex] = -mu[i];
      phi[Nex] = phi[i] * (pri[j] - 1);
    }
  }
  for (int i = 1; i <= n; i++) d[i].push_back(1);
  for (int i = 2; i <= n; i++) {
    if (!mu[i]) continue;
    for (int j = i; j <= n; j += i) d[j].push_back(i);
  }
  c[1].push_back(1);
  for (int i = 2; i <= n; i++) {
    int q = i, p = d[i][1], p1 = 0, p3 = 0;
    while (q % p == 0) q /= p;
    for (int j = 0; j < d[i].size(); j++) {
      int z = d[i][j];
      if (z % p != 0) {
        while (d[q][p1] != z) ++p1;
        c[i].push_back(c[q][p1]);
      } else {
        int now = z / p, tmp;
        while (d[q][p3] != now) ++p3;
        tmp = (1LL * (Inv[p - 1]) * (c[q][p3]) % mo);
        c[i].push_back(tmp);
      }
    }
  }
}
int main() {
  Pre_Work();
  Dfs1(1, n);
  cout << (1LL * ((1LL * (2) * (Ans) % mo)) *
           ((1LL * (Inv[n]) * (Inv[n - 1]) % mo)) % mo)
       << endl;
  return 0;
}