func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 5;   const int oo = 0x3f3f3f3f;   const int LIM = 2e5;   int N, a[MAXN], num[MAXN], top, f[MAXN], ans[MAXN];   vector<int> S[MAXN];   int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }   namespace Graph {   struct edge {     int y, next;   } e[MAXN << 1];   int LINK[MAXN], len = 0;   inline void ins(int x, int y) {     e[++len].next = LINK[x];     LINK[x] = len;     e[len].y = y;   }   inline void Ins(int x, int y) {     ins(x, y);     ins(y, x);   }   void DFS(int node, int fa) {     top = 0;     S[node].push_back(f[fa]);     f[node] = gcd(f[fa], a[node]);     ans[node] = max(ans[node], f[node]);     for (int i = 0; i <= (int)S[fa].size() - 1; i++)       num[++top] = gcd(S[fa][i], a[node]);     num[++top] = f[fa];     sort(num + 1, num + top + 1);     top = unique(num + 1, num + top + 1) - (num + 1);     ans[node] = max(ans[node], num[top]);     for (int i = 1; i <= top; i++) S[node].push_back(num[i]);     for (int i = LINK[node]; i; i = e[i].next)       if (e[i].y != fa) DFS(e[i].y, node);   }   }  // namespace Graph   using namespace Graph;   namespace solution {   void Prepare() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) scanf( %d , &a[i]);     for (int i = 2; i <= N; i++) {       int x, y;       scanf( %d%d , &x, &y);       Ins(x, y);     }   }   void Solve() {     DFS(1, 0);     for (int i = 1; i <= N; i++) printf( %d  , ans[i]);     puts(  );   }   }  // namespace solution   int main() {     using namespace solution;     Prepare();     Solve();     return 0;   }   