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::bitset;
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::make_pair;
using std::map;
using std::pair;
using std::priority_queue;
using std::queue;
using std::set;
using std::string;
using std::stringstream;
using std::vector;
class MyTimer {
 public:
  void reset() {}
  void report() {}
} myTimer;
template <typename A, typename B>
std::ostream &operator<<(std::ostream &cout, const pair<A, B> &x) {
  return cout << "(" << x.first << ", " << x.second << ")";
}
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
  return a > b ? a = b, true : false;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
  return a < b ? a = b, true : false;
}
inline int readint() {
  int a = 0;
  char c = getchar(), p = 0;
  while (isspace(c)) c = getchar();
  if (c == '-') p = 1, c = getchar();
  while (isdigit(c)) a = a * 10 + c - '0', c = getchar();
  return p ? -a : a;
}
inline long long readLL() {
  long long a = 0;
  char c = getchar(), p = 0;
  while (isspace(c)) c = getchar();
  if (c == '-') p = 1, c = getchar();
  while (isdigit(c)) a = a * 10 + c - '0', c = getchar();
  return p ? -a : a;
}
const int maxN = 200000 + 233;
const long long P = 1000000007;
int n;
vector<int> G[maxN];
long long qpow(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) (r *= a) %= P;
    b >>= 1;
    (a *= a) %= P;
  }
  return r;
}
void inc(long long &x, long long y) { (x += y) >= P ? x -= P : x; }
void dec(long long &x, long long y) { (x -= y) < 0 ? x += P : x; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long inv[maxN], phi[maxN], dphi[maxN], c[maxN];
vector<int> divisors[maxN];
void initialize() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  static int p[maxN];
  for (int u = 1; u <= n; ++u) cin >> p[u];
  for (int u = 1; u <= n; ++u) G[u].clear();
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    x = p[x];
    y = p[y];
    G[x].push_back(y);
    G[y].push_back(x);
  }
  memset(phi, 0, sizeof(phi));
  for (int i = 1; i <= n; ++i) inv[i] = qpow(i, P - 2);
  for (int i = 1; i <= n; ++i) divisors[i].clear();
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; j += i) divisors[j].push_back(i);
  auto get_phi = [&](int x) -> long long {
    long long r = x;
    while (x > 1) {
      int i = divisors[x][1];
      while (x % i == 0) x /= i;
      r = r / i * (i - 1);
    }
    return r;
  };
  for (int i = 1; i <= n; ++i)
    phi[i] = get_phi(i), dphi[i] = i * qpow(phi[i], P - 2) % P;
  for (int i = 1; i <= n; ++i) {
    c[i] += dphi[i];
    c[i] %= P;
    c[i] += P;
    c[i] %= P;
    for (int j = i * 2; j <= n; j += i) c[j] -= c[i];
  }
}
long long ans = 0;
bool done[maxN];
int tot, bestv = 0x3f3f3f3f, center = -1;
int DFSCenter(int u, int fa) {
  int sz = divisors[u].size(), max = 0;
  for (int v : G[u])
    if (v != fa && !done[v]) {
      int cc = DFSCenter(v, u);
      sz += cc;
      chmax(max, cc);
    }
  chmax(max, tot - sz);
  chmin(bestv, max) && (center = u);
  return sz;
}
int DFSSize(int u, int fa) {
  int sz = divisors[u].size();
  for (int v : G[u])
    if (v != fa && !done[v]) sz += DFSSize(v, u);
  return sz;
}
vector<pair<int, int> > f, g;
void DFS(int u, int fa, int dep) {
  f.emplace_back(u, dep);
  for (int v : G[u])
    if (v != fa && !done[v]) {
      DFS(v, u, dep + 1);
    }
}
long long calc(vector<pair<int, int> > &a) {
  static long long f[maxN];
  long long res = 0;
  if (a.size() < 0) {
    for (auto i = a.begin(); i != a.end(); ++i)
      for (auto j = a.begin(); j != i; ++j) {
        long long x = i->first, y = j->first, d = i->second + j->second,
                  g = gcd(x, y);
        inc(res, d * phi[x] % P * phi[y] % P * dphi[g] % P);
      }
  } else {
    for (pair<int, int> p : a) {
      for (int d : divisors[p.first]) {
        inc(f[d], phi[p.first]);
      }
    }
    for (pair<int, int> p : a) {
      long long dans = 0;
      for (int d : divisors[p.first]) {
        inc(dans, (P - phi[p.first] + f[d] * c[d]) % P);
      }
      dans = dans * p.second % P * phi[p.first] % P;
      inc(res, dans);
    }
    for (pair<int, int> p : a) {
      for (int d : divisors[p.first]) f[d] = 0;
    }
  }
  inc(res, res);
  return res;
}
void solve(int u) {
  bestv = 0x3f3f3f3f;
  center = -1;
  int cur_size = DFSCenter(u, -1);
  assert(cur_size == tot);
  u = center;
  f.clear();
  g.clear();
  long long dans = 0;
  for (int v : G[u])
    if (!done[v]) {
      DFS(v, u, 1);
      dans -= calc(f);
      g.insert(g.end(), f.begin(), f.end());
      f.clear();
    }
  g.emplace_back(u, 0);
  dans += calc(g);
  dans %= P;
  dans += P;
  dans %= P;
  ans = (ans + dans) % P;
  done[u] = true;
  for (int v : G[u])
    if (!done[v]) {
      tot = DFSSize(v, -1);
      solve(v);
    }
}
int main() {
  initialize();
  memset(done, 0, sizeof(done));
  tot = 0;
  for (int i = 1; i <= n; ++i) tot += divisors[i].size();
  solve(1);
  ans = ans * qpow(n, P - 2) % P * qpow(n - 1, P - 2) % P;
  cout << ans << endl;
  return 0;
}