#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int u, long long int v) {
  int shift;
  if (u == 0) return v;
  if (v == 0) return u;
  shift = __builtin_ctzll(u | v);
  u >>= __builtin_ctzll(u);
  do {
    v >>= __builtin_ctzll(v);
    if (u > v) {
      long long int t = v;
      v = u;
      u = t;
    }
    v = v - u;
  } while (v != 0);
  return u << shift;
}
vector<map<long long int, long long int>> cnts(1e5 + 8);
long long int dfs(vector<long long int>& vals, vector<vector<int>>& v, int u,
                  int par, int pos = 0) {
  auto& curr = cnts[pos];
  auto& next = cnts[pos + 1];
  long long int res = 0;
  for (auto& vv : v[u]) {
    if (par == vv) {
      continue;
    }
    long long int new_val = vals[vv];
    next.clear();
    next[new_val] = 1;
    res = (res + new_val) % 1000000007;
    for (auto& x : curr) {
      long long int g = gcd(x.first, new_val);
      next[g] += x.second;
      res = (res + (g % 1000000007) * x.second) % 1000000007;
    }
    res += dfs(vals, v, vv, u, pos + 1);
    res %= 1000000007;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  vector<long long int> vals(n + 1, 0);
  vector<vector<int>> v(n + 1);
  for (int i = 1; i < n + 1; i++) {
    cin >> vals[i];
  }
  v[0].push_back(1);
  v[1].push_back(0);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  cout << dfs(vals, v, 0, -1) << "\n";
  return 0;
}
