#include <bits/stdc++.h>
using namespace std;
inline bool scan_d(long long &num) {
  char in;
  bool IsN = false;
  in = getchar();
  if (in == EOF) return false;
  while (in != '-' && (in < '0' || in > '9')) in = getchar();
  if (in == '-') {
    IsN = true;
    num = 0;
  } else
    num = in - '0';
  while (in = getchar(), in >= '0' && in <= '9') {
    num *= 10, num += in - '0';
  }
  if (IsN) num = -num;
  return true;
}
inline bool scan_d(int &num) {
  char in;
  bool IsN = false;
  in = getchar();
  if (in == EOF) return false;
  while (in != '-' && (in < '0' || in > '9')) in = getchar();
  if (in == '-') {
    IsN = true;
    num = 0;
  } else
    num = in - '0';
  while (in = getchar(), in >= '0' && in <= '9') {
    num *= 10, num += in - '0';
  }
  if (IsN) num = -num;
  return true;
}
struct node {
  long long res;
  int cnt;
  node() {}
  node(long long r, int c) {
    res = r;
    cnt = c;
  }
};
vector<node> ne[200010];
node rr[200010];
vector<int> e[200010];
bool cmp(node a, node b) { return a.res < b.res; }
long long ans;
long long a[200010];
long long gcd(long long x, long long y) {
  if (x == 0) return y;
  if (y == 0) return x;
  return gcd(y, x % y);
}
void dfs(int x, int y) {
  int cnt = 0;
  rr[++cnt].res = a[x];
  rr[cnt].cnt = 1;
  for (int i = 0; i < ne[y].size(); i++) {
    rr[++cnt].res = gcd(ne[y][i].res, a[x]);
    rr[cnt].cnt = ne[y][i].cnt;
  }
  sort(rr + 1, rr + cnt + 1, cmp);
  long long xx = rr[1].res;
  int yy = rr[1].cnt;
  for (int i = 2; i <= cnt; i++) {
    if (rr[i].res == xx) {
      yy += rr[i].cnt;
    } else {
      ans = (ans + xx * yy) % 1000000007;
      ne[x].push_back(node(xx, yy));
      xx = rr[i].res;
      yy = rr[i].cnt;
    }
  }
  ans = (ans + xx * yy) % 1000000007;
  ne[x].push_back(node(xx, yy));
  for (int i = 0; i < e[x].size(); i++) {
    int to = e[x][i];
    if (to == y) continue;
    dfs(to, x);
  }
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scan_d(a[i]);
  }
  for (int i = 1; i < n; i++) {
    scan_d(x);
    scan_d(y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1, 1);
  printf("%lld\n", ans);
  return 0;
}
