func_code_string: #include <bits/stdc++.h>   long long MOD = 1e9 + 7;   using namespace std;   int in() {     int x;     scanf( %d , &x);     return x;   }   long long lin() {     long long x;     scanf( %lld , &x);     return x;   }   template <typename A, size_t NNN, typename T>   void Fill(A (&array)[NNN], const T &val) {     fill((T *)array, (T *)(array + NNN), val);   }   struct custom_hash {     static uint64_t splitmix64(uint64_t x) {       x += 0x9e3779b97f4a7c15;       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;       return x ^ (x >> 31);     }     size_t operator()(uint64_t x) const {       static const uint64_t FIXED_RANDOM =           chrono::steady_clock::now().time_since_epoch().count();       return splitmix64(x + FIXED_RANDOM);     }   };   struct pair_hash {     template <class T1, class T2>     size_t operator()(const pair<T1, T2> &p) const {       return hash<T1>()(p.first) ^ hash<T2>()(p.second);     }   };   vector<pair<long long, long long> > G[400001];   long long ans[400001], w[400001];   long long s;   long long dfs(int t, int p) {     long long temp1 = w[t], temp2 = 0;     for (int i = 0; i < G[t].size(); i++) {       if (G[t][i].first == p) continue;       temp2 = max(temp2, dfs(G[t][i].first, t) + w[t] - G[t][i].second);       if (temp2 > temp1) swap(temp1, temp2);     }     s = max(s, temp1 + temp2 - w[t]);     return temp1;   }   int main() {     long long n = lin();     for (long long i = 1; i <= n; ++i) w[i] = lin();     for (long long i = 1; i <= n; ++i) {       ans[i] = w[i];     }     for (int i = 0; i < n - 1; i++) {       long long u = lin(), v = lin(), c = lin();       G[u].push_back({v, c});       G[v].push_back({u, c});     }     s = max(s, dfs(1, 0));     for (long long i = 1; i <= n; ++i) s = max(s, w[i]);     cout << s;   }   