#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<pair<ll, ll>> gr[(ll)(3e5 + 3)];
ll ma = 0;
ll ar[(ll)(3e5 + 3)];
ll su[(ll)(3e5 + 3)];
ll dfs(pair<ll, ll> node, ll par) {
  ll m1 = 0, m2 = 0;
  for (auto x : gr[node.first]) {
    if (x.first != par) {
      ll te = dfs(x, node.first);
      if (te > m1) {
        m2 = m1;
        m1 = te;
      } else if (te > m2) {
        m2 = te;
      }
    }
  }
  ar[node.first - 1] += m1;
  ma = max(ma, ar[node.first - 1] + m2);
  return ar[node.first - 1] - node.second;
}
int main() {
  ll n;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> ar[i];
  }
  ma = ar[0];
  ll a, b, c;
  for (ll i = 0; i < n - 1; i++) {
    cin >> a >> b >> c;
    gr[a].push_back(make_pair(b, c));
    gr[b].push_back(make_pair(a, c));
  }
  if (n > 1) {
    dfs(make_pair(a, c), 0);
  }
  cout << ma << "\n";
}
