#include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1e5 + 10;
struct edge {
  long long v, w, nxt;
} E[maxn * 2];
long long p[maxn], eid;
long long dp[maxn];
void init() {
  memset(p, -1, sizeof p);
  eid = 0;
}
void insert(long long u, long long v, long long w) {
  E[eid].v = v;
  E[eid].w = w;
  E[eid].nxt = p[u];
  p[u] = eid++;
}
void insert2(long long u, long long v, long long w) {
  insert(u, v, w);
  insert(v, u, w);
}
long long n;
long long pv[maxn];
long long ans = -9999999999;
void dfs(long long u, long long fa) {
  dp[u] = pv[u];
  long long fmax = 0, smax = 0;
  for (register long long i = p[u]; ~i; i = E[i].nxt) {
    long long v = E[i].v, w = E[i].w;
    if (v == fa) continue;
    dfs(v, u);
    long long now = dp[v] - w;
    if (now > fmax) {
      smax = fmax;
      fmax = now;
    } else if (now > smax) {
      smax = now;
    }
    dp[u] = max(dp[u], dp[v] - w + pv[u]);
  }
  ans = max(ans, max(dp[u], smax + fmax + pv[u]));
}
signed main() {
  scanf("%lld", &n);
  init();
  for (register long long i = 1; i <= n; i++) scanf("%lld", pv + i);
  for (register long long i = 1; i <= n - 1; i++) {
    long long u, v, w;
    scanf("%lld%lld%lld", &u, &v, &w);
    insert2(u, v, w);
  }
  dfs(1, -1);
  printf("%lld\n", ans);
  return 0;
}
