#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return x * f;
}
const int N = 100006;
const int mod = 1e9 + 7;
vector<pair<long long, long long> > val[N];
vector<int> g[N];
int n;
long long gcd(long long x, long long y) {
  if (!x || !y) return x + y;
  return gcd(y, x % y);
}
long long ans;
void dfs(int u, int fa) {
  map<long long, long long> mp;
  for (register int i = 0; i < val[fa].size(); ++i) {
    long long GCD = gcd(val[fa][i].first, val[u][0].first);
    mp[GCD] = (mp[GCD] + val[fa][i].second) % mod;
  }
  for (map<long long, long long>::iterator it = mp.begin(); it != mp.end();
       ++it)
    val[u].push_back(make_pair(it->first, it->second)),
        ans = (ans + it->first * it->second) % mod;
  for (register int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs(v, u);
  }
}
int main() {
  n = rd();
  for (register int i = 1; i <= n; ++i) {
    long long x;
    scanf("%lld", &x);
    val[i].push_back(make_pair(x, 1));
    ans = (ans + x) % mod;
  }
  for (register int i = 1; i < n; ++i) {
    int x = rd(), y = rd();
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
