#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5 + 5;
const long long INF = 1e18;
struct EDGE {
  long long next, to, w;
} edge[MAXN * 2];
long long head[MAXN], tot;
inline void add(long long x, long long y, long long z) {
  edge[++tot].next = head[x];
  edge[tot].to = y;
  edge[tot].w = z;
  head[x] = tot;
}
long long n, w[MAXN], max_link[MAXN], dp[MAXN];
void dfs(long long u, long long fa) {
  long long link1 = -INF, link2 = -INF;
  dp[u] = w[u];
  for (long long i = head[u]; i; i = edge[i].next) {
    long long v = edge[i].to;
    if (v == fa) continue;
    dfs(v, u);
    max_link[u] = max(max_link[u], max_link[v] - edge[i].w);
    if (max_link[v] - edge[i].w > link1) {
      link2 = link1;
      link1 = max_link[v] - edge[i].w;
    } else if (max_link[v] - edge[i].w > link2)
      link2 = max_link[v] - edge[i].w;
    dp[u] = max(dp[u], dp[v]);
  }
  max_link[u] += w[u];
  dp[u] = max(dp[u], link1 + w[u]);
  dp[u] = max(dp[u], link1 + link2 + w[u]);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> w[i];
  for (long long i = 1; i < n; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    add(u, v, c);
    add(v, u, c);
  }
  dfs(1, 0);
  cout << dp[1] << endl;
  return 0;
}
