func_code_string: #include <bits/stdc++.h>   using namespace std;   const int M = 1e6 + 20;   struct Edge {     int to, w, next;   } edge[M];   int head[M], cnt, fa[M];   inline void add(int u, int v, int w) {     edge[++cnt].to = v, edge[cnt].w = w, edge[cnt].next = head[u], head[u] = cnt;   }   long long mxp[M];   int val[M];   long long dfs1(int now) {     mxp[now] = val[now];     for (int i = head[now]; i; i = edge[i].next) {       if (edge[i].to == fa[now]) continue;       fa[edge[i].to] = now,       mxp[now] = max(mxp[now], val[now] - edge[i].w + dfs1(edge[i].to));     }     return mxp[now];   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &val[i]);     for (int i = 1; i <= n - 1; ++i) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w), add(u, v, w), add(v, u, w);     }     dfs1(1);     long long ans = 0;     for (int i = 1; i <= n; ++i) {       long long mx1 = 0, mx2 = 0;       for (int j = head[i]; j; j = edge[j].next) {         if (edge[j].to == fa[i]) continue;         long long c = mxp[edge[j].to] - edge[j].w;         if (c > mx1)           mx2 = mx1, mx1 = c;         else if (c > mx2)           mx2 = c;       }       ans = max(ans, val[i] + mx1 + mx2);     }     printf( %lld n , ans);     return 0;   }   