#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 3e5 + 5;
struct edge {
  int v;
  ll c;
};
int n;
ll w[MAXN], dp[MAXN], ans;
vector<edge> adj[MAXN];
void dfs(int u, int p) {
  ll t1 = -1e18, t2 = -1e18;
  dp[u] = w[u];
  for (edge e : adj[u]) {
    if (e.v != p) {
      dfs(e.v, u);
      dp[u] = max(dp[u], w[u] - e.c + dp[e.v]);
      if (dp[e.v] - e.c > t1)
        t2 = t1, t1 = dp[e.v] - e.c;
      else if (dp[e.v] - e.c > t2)
        t2 = dp[e.v] - e.c;
    }
  }
  ans = max({ans, dp[u], t1 + t2 + w[u]});
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> w[i];
  for (int i = 1; i < n; ++i) {
    int u, v;
    ll c;
    cin >> u >> v >> c;
    adj[u].push_back((edge){v, c});
    adj[v].push_back((edge){u, c});
  }
  dfs(1, -1);
  cout << ans;
  return 0;
}
