#include <bits/stdc++.h>
using namespace std;
namespace Tzh {
const int maxn = 300010;
int n, head[maxn], cnt;
long long dp[maxn], ans, g[maxn];
struct ed {
  int next, to;
  long long w;
} e[maxn << 1];
void add(int u, int v, long long w) {
  e[++cnt] = (ed){head[u], v, w};
  head[u] = cnt;
  e[++cnt] = (ed){head[v], u, w};
  head[v] = cnt;
}
void dfs(int now, int f) {
  dp[now] = g[now];
  for (int i = head[now]; i; i = e[i].next) {
    int tt = e[i].to;
    if (tt == f) continue;
    dfs(tt, now);
    ans = max(ans, dp[now] + dp[tt] - e[i].w);
    dp[now] = max(dp[now], dp[tt] - e[i].w + g[now]);
  }
}
void work() {
  scanf("%d", &n);
  int u, v;
  long long w;
  for (int i = 1; i <= n; i++) scanf("%lld", &g[i]);
  for (int i = 1; i < n; i++) scanf("%d%d%lld", &u, &v, &w), add(u, v, w);
  ans = *max_element(g + 1, g + n + 1);
  dfs(1, 0);
  printf("%lld", ans);
  return;
}
}  // namespace Tzh
int main() {
  Tzh::work();
  return 0;
}
