#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long v, nxt;
} e[100005 << 1];
long long top = 1;
long long head[100005];
void Add_Edge(long long u, long long v) {
  e[++top] = edge{v, head[u]};
  head[u] = top;
  e[++top] = edge{u, head[v]};
  head[v] = top;
}
long long n;
long long val[100005];
set<long long> s[100005];
map<long long, long long> cnt[100005];
long long Ans;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
void dfs(long long u, long long fa) {
  for (register long long i = head[u]; i; i = e[i].nxt) {
    long long v = e[i].v;
    if (v == fa) continue;
    for (auto j : s[u]) {
      long long get = gcd(j, val[v]);
      Ans = (Ans + get * cnt[u][j] % 1000000007) % 1000000007;
      cnt[v][get] = (cnt[v][get] + cnt[u][j]) % 1000000007;
      s[v].insert(get);
    }
    s[v].insert(val[v]);
    Ans = (Ans + val[v]) % 1000000007;
    cnt[v][val[v]]++;
    dfs(v, u);
  }
}
long long read() {
  long long x = 0;
  char c = getchar();
  long long f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
void write(long long x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
signed main() {
  n = read();
  for (register long long i = 1; i <= n; ++i) val[i] = read();
  for (register long long i = 2; i <= n; ++i) {
    long long u = read(), v = read();
    Add_Edge(u, v);
  }
  Ans = val[1] % 1000000007;
  s[1].insert(val[1]);
  cnt[1][val[1]]++;
  dfs(1, 0);
  write(Ans % 1000000007), putchar('\n');
  return 0;
}
