func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<long long int> x;   vector<vector<int> > adjList;   vector<bool> visited;   long long int ans = 0;   long long int add(long long int a, long long int b) {     return (a + b) % 1000000007;   }   long long int mul(long long int a, long long int b) {     return (a * b) % 1000000007;   }   long long int gcd(long long int a, long long int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   void dfs(int node, unordered_map<long long int, long long int> mp) {     long long int gc;     unordered_map<long long int, long long int> mp2;     for (auto elem : mp) {       gc = gcd(elem.first, x[node]);       ans = add(ans, mul(gc, elem.second));       mp2[gc] += elem.second;     }     ans = add(x[node], ans);     mp2[x[node]] += 1LL;     for (auto elem : adjList[node]) {       if (!visited[elem]) {         visited[elem] = true;         dfs(elem, mp2);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     x.resize(n + 1, 0);     visited.resize(n + 1, false);     adjList.resize(n + 1);     for (register int i = 1; i <= n; i++) cin >> x[i];     int a, b;     for (int i = 1; i < n; i++) {       cin >> a >> b;       adjList[a].push_back(b);       adjList[b].push_back(a);     }     unordered_map<long long int, long long int> mp;     visited[1] = true;     dfs(1, mp);     cout << ans <<   n ;     return 0;   }   