#include <bits/stdc++.h>
using namespace std;
const long long MAXX = 300005;
struct node {
  long long to, w;
  node() {}
  node(long long T, long long W) { to = T, w = W; }
};
vector<node> g[MAXX];
bool vis[MAXX];
long long pri[MAXX];
long long dp[MAXX];
long long a, b, c;
long long ans;
long long n;
void dfs(long long x, long long fa) {
  ans = max(ans, dp[x]);
  for (long long i = 0; i < g[x].size(); i++) {
    long long next = g[x][i].to;
    if (next == fa) continue;
    dfs(next, x);
    long long v = dp[next] - g[x][i].w;
    ans = max(ans, dp[x] + v);
    dp[x] = max(dp[x], pri[x] + v);
  }
  return;
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &dp[i]);
    pri[i] = dp[i];
  }
  for (long long i = 1; i < n; i++) {
    scanf("%lld %lld %lld", &a, &b, &c);
    g[a].push_back(node(b, c));
    g[b].push_back(node(a, c));
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
