func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int maxn = 1e5 + 100;   long long a[maxn];   map<long long, long long> p[maxn];   vector<int> G[maxn];   long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }   long long ans = 0;   void dfs(int v, int fa) {     for (auto it : p[fa]) {       long long t = gcd(a[v], it.first);       p[v][t] += it.second;       ans = (ans + t % mod * it.second % mod) % mod;     }     p[v][a[v]] += 1;     ans = (ans + a[v]) % mod;     for (int i = 0; i < G[v].size(); i++) {       int to = G[v][i];       if (to == fa) continue;       dfs(to, v);     }   }   int main() {     std::ios::sync_with_stdio(false);     int N;     cin >> N;     for (int i = 1; i <= N; i++) cin >> a[i];     for (int i = 1; i < N; i++) {       int x;       int y;       cin >> x >> y;       G[x].push_back(y);       G[y].push_back(x);     }     dfs(1, 0);     cout << ans << endl;     return 0;   }   