func_code_string: #include <bits/stdc++.h>   using namespace std;   bool visited[300000];   long long int parent[300000];   void initialise() {     for (long long int i = 0; i < 300000; i++) {       visited[i] = false;       parent[i] = i;     }   }   pair<long long int, long long int> dfs(       vector<pair<long long int, long long int>> adj[], long long int A[],       long long int v, long long int i) {     visited[i] = true;     pair<long long int, long long int> r, s;     long long int j, k = adj[i].size();     long long int d = 0, f = 0;     r.first = A[i];     for (j = 0; j < k; j++) {       if (!visited[adj[i][j].first]) {         s = dfs(adj, A, v, adj[i][j].first);         r.first = max(r.first, s.first);         r.first = max(r.first, d + s.second + adj[i][j].second + A[i]);         d = max(d, s.second + adj[i][j].second);       }     }     r.second = d + A[i];     return r;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int u, v, x, y, a, b, i, k, l, p, n, m, w, maxi = 0, ans;     pair<long long int, long long int> j;     cin >> v;     vector<pair<long long int, long long int>> adj[v];     long long int A[v];     initialise();     for (i = 0; i < v; i++) {       cin >> A[i];     }     for (i = 0; i < v - 1; i++) {       cin >> x >> y >> w;       x--;       y--;       adj[x].push_back(make_pair(y, -w));       adj[y].push_back(make_pair(x, -w));     }     j = dfs(adj, A, v, 0);     cout << j.first;   }   