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;
char buf[25];
const int maxn = 200010;
const int mod = 1000000007;
const int dep = 18;
struct edge {
  int n, t;
} e[maxn * 2], te[maxn * 2];
vector<int> V1[maxn], V2[maxn];
bool b[maxn];
int p[maxn], u[maxn], phi[maxn];
int v[maxn], w[maxn], h[maxn], th[maxn], dfn[maxn], d[maxn], f[maxn][dep + 1];
int tp[maxn], dp[maxn], st[maxn], F[maxn];
int n, enct, tenct, prime, times, point, tail, sum, ans;
long long read() {
  long long x = 0, f = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = 1;
  } while (ch < '0' || ch > '9');
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return f ? -x : x;
}
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  int cnt = 0;
  while (x) {
    buf[++cnt] = '0' + x % 10;
    x /= 10;
  }
  for (int i = cnt; i >= 1; --i) putchar(buf[i]);
}
void add(int x, int y) {
  e[++enct] = (edge){h[x], y};
  h[x] = enct;
}
void perpare() {
  for (int i = 1; i <= n; ++i) b[i] = true;
  b[1] = false;
  u[1] = 1;
  phi[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (b[i]) {
      p[++prime] = i;
      u[i] = -1;
      phi[i] = i - 1;
    }
    for (int j = 1; j <= prime; ++j) {
      if (n / p[j] < i) break;
      int x = p[j] * i;
      b[x] = false;
      if (i % p[j] == 0) {
        u[x] = 0;
        phi[x] = phi[i] * p[j];
        break;
      }
      u[x] = u[i] * u[p[j]];
      phi[x] = phi[i] * phi[p[j]];
    }
  }
}
void init(int x) {
  for (int i = 1; i <= dep; ++i) f[x][i] = f[f[x][i - 1]][i - 1];
}
void dfs(int x) {
  dfn[x] = ++times;
  for (int i = h[x]; i; i = e[i].n) {
    int y = e[i].t;
    if (y != f[x][0]) {
      f[y][0] = x;
      d[y] = d[x] + 1;
      init(y);
      dfs(y);
    }
  }
}
bool cmp(int x, int y) { return dfn[x] < dfn[y]; }
void tadd(int x, int y) {
  te[++tenct] = (edge){th[x], y};
  th[x] = tenct;
}
int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  int tmp = (d[x] - d[y]);
  for (int i = 0; i <= dep; ++i)
    if ((1 << i) & tmp) x = f[x][i];
  if (x != y) {
    for (int i = dep; i >= 0; --i)
      if (f[x][i] != f[y][i]) {
        x = f[x][i];
        y = f[y][i];
      }
    return f[x][0];
  } else
    return x;
}
void build() {
  tail = 0;
  st[++tail] = 0;
  st[++tail] = tp[1];
  dp[0] = 0;
  dp[tp[1]] = phi[v[tp[1]]];
  for (int i = 2; i <= point; ++i) {
    int x = lca(st[tail], tp[i]);
    while (d[st[tail]] > d[x]) {
      if (d[st[tail - 1]] < d[x])
        tadd(x, st[tail]);
      else
        tadd(st[tail - 1], st[tail]);
      --tail;
    }
    if (st[tail] != x) st[++tail] = x, dp[x] = 0;
    st[++tail] = tp[i];
    dp[tp[i]] = phi[v[tp[i]]];
  }
  while (tail > 1) {
    tadd(st[tail - 1], st[tail]);
    --tail;
  }
}
void dp1(int x) {
  for (int i = th[x]; i; i = te[i].n) {
    int y = te[i].t;
    dp1(y);
    dp[x] = (dp[x] + dp[y]) % mod;
  }
}
void dp2(int x) {
  for (int i = th[x]; i; i = te[i].n) {
    int y = te[i].t;
    sum = (sum +
           1ll * (d[y] - d[x]) * (dp[0] - dp[y] + mod) % mod * dp[y] % mod) %
          mod;
    dp2(y);
  }
  th[x] = 0;
}
int ksm(int x, int y) {
  int ans = 1;
  for (; y; y >>= 1) {
    if (y & 1) ans = 1ll * ans * x % mod;
    x = 1ll * x * x % mod;
  }
  return ans;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) v[i] = read(), w[i] = i;
  for (int i = 1; i <= n - 1; ++i) {
    int x = read(), y = read();
    add(x, y);
    add(y, x);
  }
  perpare();
  d[1] = 1;
  dfs(1);
  sort(w + 1, w + 1 + n, cmp);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n / i; ++j) V1[j * i].push_back(i);
  for (int i = 1; i <= n; ++i) {
    int x = w[i], y = v[x];
    for (int j = 0; j <= V1[y].size() - 1; ++j) V2[V1[y][j]].push_back(x);
  }
  for (int i = 1; i <= n; ++i) {
    tenct = 0;
    point = 0;
    for (int j = 0; j <= V2[i].size() - 1; ++j) tp[++point] = V2[i][j];
    build();
    sum = 0;
    dp1(0);
    dp2(0);
    F[i] = sum;
  }
  for (int i = 1; i <= n; ++i) {
    int x = 1ll * i * ksm(phi[i], mod - 2) % mod;
    for (int j = 1; j <= n / i; ++j)
      ans = (ans + 1ll * u[j] * F[i * j] % mod * x % mod + mod) % mod;
  }
  write(1ll * ans * 2 % mod * ksm(n, mod - 2) % mod * ksm(n - 1, mod - 2) %
        mod);
  putchar('\n');
  return 0;
}