func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int nax = 3e5 + 10;   long long w[nax];   long long dp[nax], ans;   vector<pair<int, long long> > v[nax];   void dfs(int id, int par) {     vector<long long> temp;     for (auto i : v[id]) {       if (i.first == par) continue;       dfs(i.first, id);       temp.emplace_back(dp[i.first] - i.second);       dp[id] = max(dp[id], dp[i.first] - i.second);     }     dp[id] += w[id];     ans = max(ans, dp[id]);     sort(temp.begin(), temp.end());     reverse(temp.begin(), temp.end());     if ((int)temp.size() == 1) ans = max(ans, temp[0] + w[id]);     if ((int)temp.size() > 1) ans = max(ans, temp[1] + temp[0] + w[id]);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     for (int i = 1; i <= n; ++i) cin >> w[i];     for (int i = 0; i < n - 1; ++i) {       int x, y, t;       cin >> x >> y >> t;       v[x].emplace_back(y, t);       v[y].emplace_back(x, t);     }     dfs(1, -1);     cout << ans <<   n ;     ;     return 0;   }   