#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
using max_heap = priority_queue<T>;
const int mod = 1000000007;
const int inf = 0x3fffffff;
const int N = 1e5 + 10;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
struct PairHash {
  template <typename T1, typename T2>
  std::size_t operator()(const pair<T1, T2> &p) const {
    return hash<T1>()(p.first) ^ hash<T2>()(p.second);
  }
};
int n;
long long b[N];
vector<vector<int>> tree;
long long ans;
void add_mod(long long a) { ans = (ans + a % mod) % mod; }
void dfs(int r, int pre, const unordered_map<long long, int> &z) {
  unordered_map<long long, int> nz;
  if (true) {
    nz[b[r]]++;
    add_mod(b[r]);
    for (auto p : z) {
      long long d = gcd(b[r], p.first);
      add_mod(d % mod * p.second);
      nz[d] += p.second;
    }
  } else {
    nz = z;
    for (auto &p : nz) {
      add_mod(p.first % mod * p.second);
      p.second++;
    }
  }
  for (auto u : tree[r]) {
    if (u == pre) continue;
    dfs(u, r, nz);
  }
}
void solve(int ncase) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &b[i]);
  }
  tree.assign(n + 1, vector<int>());
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    tree[x].push_back(y);
    tree[y].push_back(x);
  }
  dfs(1, -1, unordered_map<long long, int>());
  cout << ans << endl;
}
void solve_all_cases() {
  int T = 1;
  int ncase = 0;
  while (T--) {
    solve(++ncase);
  }
}
int main() {
  cout << std::fixed;
  cout << setprecision(9);
  solve_all_cases();
}
