#include <bits/stdc++.h>
const int maxn = 5e5 + 10, maxm = 1e6 + 10;
int w[maxn];
int cnt, to[maxm], nxt[maxm], hd[maxn], dis[maxm];
long long ans = 0, dp[maxn];
int n;
inline void add(int a, int b, int c) {
  nxt[++cnt] = hd[a];
  hd[a] = cnt;
  dis[cnt] = c;
  to[cnt] = b;
}
void dfs(int u, int fa) {
  dp[u] = w[u];
  ans = std::max(ans, dp[u]);
  for (int i = hd[u]; i; i = nxt[i]) {
    int nx = to[i];
    if (nx == fa) continue;
    dfs(nx, u);
    dp[nx] -= dis[i];
    ans = std::max(ans, dp[u] + dp[nx]);
    dp[u] = std::max(dp[u], w[u] + dp[nx]);
  }
  ans = std::max(ans, dp[u]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    add(u, v, w);
    add(v, u, w);
  }
  dfs(1, 0);
  printf("%I64d", ans);
  return 0;
}
