#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 10;
long long n, mx, ar[N], dp[N];
vector<pair<long long, long long> > adj[N];
void dfs(long long v, long long p) {
  vector<long long> vec;
  for (pair<long long, long long> i : adj[v]) {
    if (i.first != p) {
      long long u = i.first, w = i.second;
      dfs(u, v);
      vec.push_back(dp[u] - w);
    }
  }
  sort(vec.begin(), vec.end(), [&](long long a, long long b) { return a > b; });
  if (!vec.size()) {
    dp[v] = ar[v];
    mx = max(mx, dp[v]);
    return;
  } else if (vec.size() == 1) {
    if (vec.back() > 0)
      dp[v] = ar[v] + vec.back();
    else
      dp[v] = ar[v];
    mx = max(mx, dp[v]);
    return;
  }
  long long d1 = vec[0], d2 = vec[1];
  if (d1 > 0) mx = max(mx, d1 + ar[v] + d2);
  dp[v] = max(ar[v], d1 + ar[v]);
  mx = max(mx, dp[v]);
}
int32_t main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> ar[i];
  for (long long i = 1; i < n; i++) {
    long long v, u, w;
    cin >> v >> u >> w;
    v--;
    u--;
    adj[v].push_back({u, w});
    adj[u].push_back({v, w});
  }
  dfs(0, 0);
  cout << mx;
}
