func_code_string: #include <bits/stdc++.h>   using namespace std;   long long ans, f[300005];   ;   vector<pair<int, int> > adj[300005];   int w[300005];   void dfs(int v, int fa) {     f[v] = w[v];     ans = max(ans, 1ll * w[v]);     for (auto i : adj[v]) {       if (i.first != fa) {         dfs(i.first, v);         ans = max(ans, f[v] + f[i.first] - i.second);         f[v] = max(f[v], w[v] + f[i.first] - i.second);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, x, y, z;     cin >> n;     for (int i = 0; i < n; i++) cin >> w[i + 1];     for (int i = 0; i < n - 1; i++) {       cin >> x >> y >> z;       adj[x].push_back({y, z});       adj[y].push_back({x, z});     }     dfs(1, 0);     cout << ans;   }   