func_code_string: #include <bits/stdc++.h>   using namespace std;   long long f1[120000], f2[120000], f3[120000], f4[120000], ans;   vector<int> E[120000];   int n, a[120000];   void dfs1(int x, int fa) {     f1[x] = f2[x] = a[x];     for (int i : E[x])       if (i != fa) {         dfs1(i, x);         f1[x] = max(f1[i], f1[x]);         f1[x] = max(f1[x], f2[x] + f2[i]);         f2[x] = max(f2[x], f2[i] + a[x]);       }   }   void dfs2(int x, int fa) {     pair<long long, long long> ip[5];     pair<long long, long long> iq[5];     for (int i = (0); i <= (3); ++i) ip[i] = iq[i] = make_pair(-1e18, 0);     for (int i : E[x])       if (i != fa) {         ip[0] = make_pair(f2[i] + a[x], i);         sort(ip, ip + 4);         iq[0] = make_pair(f1[i], i);         sort(iq, iq + 3);       }     ip[0] = make_pair(f4[x], -1);     sort(ip, ip + 4);     for (int i : E[x])       if (i != fa) {         f3[i] = f3[x];         if (i == ip[3].second)           f3[i] = max(f3[i], ip[2].first + ip[1].first - a[x]);         else if (i == ip[2].second)           f3[i] = max(f3[i], ip[1].first + ip[3].first - a[x]);         else           f3[i] = max(f3[i], ip[2].first + ip[3].first - a[x]);         if (i == iq[2].second)           f3[i] = max(f3[i], iq[1].first);         else           f3[i] = max(f3[i], iq[2].first);         if (i == ip[3].second)           f4[i] = ip[2].first + a[i];         else           f4[i] = ip[3].first + a[i];         dfs2(i, x);       }   }   int main() {     scanf( %d , &n);     for (int i = (1); i <= (n); ++i) scanf( %d , &a[i]);     for (int i = (1); i <= (n - 1); ++i) {       int x, y;       scanf( %d%d , &x, &y);       E[x].push_back(y);       E[y].push_back(x);     }     dfs1(1, 0);     f4[1] = a[1];     dfs2(1, 0);     ans = 0;     for (int i = (1); i <= (n); ++i) ans = max(ans, f1[i] + f3[i]);     printf( %I64d n , ans);   }   