func_code_string: #include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  or c >  9 ) {       if (c ==  - ) f = -f;       c = getchar();     }     while (c >=  0  and c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x * f;   }   struct EDGE {     int to, Next;   } edge[400100];   struct DOTS {     long long cnt, num[2], all, sum, dpth;     vector<int> sons;   } dot[200100];   int n;   int h[200100], cnt;   long long ans;   bool vis[200100];   void add(int from, int to) {     edge[++cnt].to = to;     edge[cnt].Next = h[from];     h[from] = cnt;   }   void dfs(int t) {     vis[t] = 1;     dot[t].num[0]++;     for (int i = h[t]; i; i = edge[i].Next) {       int v = edge[i].to;       if (!vis[v]) {         dot[t].cnt++;         dot[t].sons.push_back(v);         dot[v].dpth = dot[t].dpth + 1;         dfs(v);         ans += dot[t].num[0] * dot[v].num[1] * 2 * dot[t].sum;         ans %= 1000000007;         ans -= dot[t].num[1] * dot[v].num[0] * 2 * dot[t].sum;         ans %= 1000000007;         dot[t].num[0] += dot[v].num[1];         dot[t].num[1] += dot[v].num[0];       }     }     ans += dot[t].sum;   }   void dp(int t) {     for (int i = 0; i < dot[t].cnt; ++i) {       int v = dot[t].sons[i];       ans += dot[v].num[0] * (dot[1].num[dot[v].dpth & 1] - dot[v].num[0]) * 2 *              dot[v].sum;       ans %= 1000000007;       ans -= dot[v].num[1] * (dot[1].num[(dot[v].dpth ^ 1) & 1] - dot[v].num[1]) *              2 * dot[v].sum;       ans %= 1000000007;       dp(v);     }   }   int main() {     n = read();     for (int i = 1; i <= n; ++i) dot[i].sum = read();     for (int i = 1; i < n; ++i) {       int u = read();       int v = read();       add(u, v);       add(v, u);     }     dfs(1);     dp(1);     ans %= 1000000007;     ans += 1000000007;     ans %= 1000000007;     printf( %lld , ans);     return 0;   }   