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 std::sort;
const int MAXN = 400200;
const int p = 1000000007;
int n;
int a[MAXN >> 1];
int pos[MAXN >> 1];
long long ans;
struct Graph {
  struct Edge {
    int to;
    int nxt;
  } edge[MAXN];
  int frm[MAXN];
  int cnt_e;
  void insert(int u, int v) {
    cnt_e++;
    edge[cnt_e].to = v;
    edge[cnt_e].nxt = frm[u];
    frm[u] = cnt_e;
  }
} T, VT;
int read() {
  int h = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') h = (h << 1) + (h << 3) + c - '0', c = getchar();
  return h;
}
int phi[MAXN >> 1], mu[MAXN >> 1];
int prm[MAXN >> 1];
int tot_p;
bool isn_p[MAXN >> 1];
long long g[MAXN >> 1];
long long ksm(long long x, int k) {
  long long anss = 1;
  while (k) {
    if (k & 1) anss = anss * x % p;
    x = x * x % p;
    k >>= 1;
  }
  return anss;
}
int add(int x, int y) { return x + y >= p ? x + y - p : x + y; }
int sub(int x, int y) { return x - y < 0 ? x - y + p : x - y; }
void pre_G() {
  phi[1] = mu[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (isn_p[i] == false) {
      prm[++tot_p] = i;
      mu[i] = -1, phi[i] = i - 1;
    }
    for (int j = 1; j <= tot_p && prm[j] * i <= n; j++) {
      int pp = prm[j];
      isn_p[pp * i] = true;
      if (i % pp == 0) {
        mu[i * pp] = 0, phi[i * pp] = phi[i] * pp;
        break;
      } else {
        mu[i * pp] = mu[i] * mu[pp], phi[i * pp] = phi[i] * phi[pp];
      }
    }
  }
  for (int d = 1; d <= n; d++) {
    long long hh = 1ll * d * ksm(phi[d], p - 2) % p;
    for (int i = d; i <= n; i += d) {
      g[i] = (g[i] + hh * mu[i / d]) % p;
    }
  }
  for (int i = 1; i <= n; i++) g[i] = (g[i] % p + p) % p;
}
int fa[MAXN];
int e[MAXN << 1];
int dep[MAXN];
int cnt_e;
int st[MAXN >> 1], ed[MAXN >> 1];
int lg[MAXN << 1];
int mnp[MAXN << 1][19];
void pre_dfs(int x, int f) {
  e[++cnt_e] = x;
  st[x] = cnt_e;
  dep[x] = dep[f] + 1;
  for (int i = T.frm[x]; i; i = T.edge[i].nxt) {
    int v = T.edge[i].to;
    if (v != f) {
      pre_dfs(v, x);
      e[++cnt_e] = x;
    }
  }
  ed[x] = cnt_e;
}
void pre_st() {
  for (int i = 2; i <= cnt_e; i++) lg[i] = lg[i >> 1] + 1;
  for (int i = 1; i <= cnt_e; i++) mnp[i][0] = e[i];
  for (int j = 1; j <= 18; j++) {
    for (int i = 1; i + (1 << j) - 1 <= cnt_e; i++) {
      int ii = i + (1 << (j - 1));
      if (dep[mnp[i][j - 1]] < dep[mnp[ii][j - 1]]) {
        mnp[i][j] = mnp[i][j - 1];
      } else
        mnp[i][j] = mnp[ii][j - 1];
    }
  }
}
int get_lca(int x, int y) {
  int l = st[x], r = ed[y];
  if (l > r) l = st[y], r = ed[x];
  int j = lg[r - l + 1];
  int ll = r - (1 << j) + 1;
  if (dep[mnp[l][j]] < dep[mnp[ll][j]])
    return mnp[l][j];
  else
    return mnp[ll][j];
}
int staV[MAXN], tot_V;
int in_V[MAXN];
int opt[MAXN << 1], cnt_o;
int stan[MAXN], tot_n;
int sum[MAXN];
bool cmp1(int x, int y) { return st[x] < st[y]; }
bool cmp2(int x, int y) {
  int k1 = x > 0 ? st[x] : ed[-x];
  int k2 = y > 0 ? st[y] : ed[-y];
  if (k1 == k2) return x > y;
  return k1 < k2;
}
void build() {
  sort(staV, staV + tot_V + 1, cmp1);
  for (int i = 1; i <= tot_V; i++) {
    opt[++cnt_o] = staV[i];
    opt[++cnt_o] = -staV[i];
  }
  for (int i = 2; i <= tot_V; i++) {
    int lca = get_lca(staV[i - 1], staV[i]);
    if (in_V[lca] == 0) {
      in_V[lca] = 2;
      opt[++cnt_o] = lca;
      opt[++cnt_o] = -lca;
    }
  }
  if (in_V[1] == 0) {
    in_V[1] = 2;
    opt[++cnt_o] = 1;
    opt[++cnt_o] = -1;
  }
  sort(opt + 1, opt + cnt_o + 1, cmp2);
  for (int i = 1; i <= cnt_o; i++) {
    if (opt[i] > 0) {
      if (opt[i] != 1) VT.insert(stan[tot_n], opt[i]);
      stan[++tot_n] = opt[i];
    } else {
      tot_n--;
    }
  }
}
void clr() {
  for (int i = 1; i <= cnt_o; i++) {
    if (opt[i] > 0) {
      in_V[opt[i]] = false;
      VT.frm[opt[i]] = 0;
      sum[opt[i]] = 0;
    }
  }
  cnt_o = tot_V = 0;
  VT.cnt_e = 0;
}
long long ans2;
void DP(int x) {
  int sumn = in_V[x] == 1 ? phi[a[x]] : 0;
  ans2 = add(ans2, 1ll * sumn * sumn % p * dep[x] % p);
  for (int i = VT.frm[x]; i; i = VT.edge[i].nxt) {
    int v = VT.edge[i].to;
    DP(v);
    ans2 = add(ans2, 1ll * sumn * sum[v] % p * 2 * dep[x] % p);
    sumn = add(sumn, sum[v]);
  }
  sum[x] = sumn;
}
void work() {
  for (int t = 1; t <= n; t++) {
    long long anst = 0;
    long long ans1 = 0, sumf = 0;
    ans2 = 0;
    for (int i = t; i <= n; i += t) {
      ans1 = add(ans1, 1ll * phi[i] * dep[pos[i]] % p);
      sumf = add(sumf, phi[i]);
      staV[++tot_V] = pos[i];
      in_V[pos[i]] = 1;
    }
    anst = ans1 * sumf * 2 % p;
    build();
    DP(1);
    ans2 = add(ans2, ans2);
    clr();
    ans = add(ans, 1ll * g[t] * sub(anst, ans2) % p);
  }
}
int main() {
  n = read();
  pre_G();
  for (int i = 1; i <= n; i++) a[i] = read(), pos[a[i]] = i;
  for (int i = 1; i <= n - 1; i++) {
    int u = read(), v = read();
    T.insert(u, v);
    T.insert(v, u);
  }
  pre_dfs(1, 1);
  pre_st();
  work();
  printf("%lld\n", ans * ksm(1ll * n * (n - 1) % p, p - 2) % p);
  return 0;
}