#include <bits/stdc++.h>
using namespace std;
const long long MAXN = (long long)6e5 + 10;
long long n;
long long a[MAXN];
long long head[MAXN], ver[MAXN], nxt[MAXN], edge[MAXN], E = 0;
long long dp[MAXN], ans = -1e17;
void add(long long x, long long y, long long z) {
  ver[++E] = y;
  edge[E] = z;
  nxt[E] = head[x];
  head[x] = E;
}
void check_max(long long &x, long long y) {
  if (x < y) x = y;
}
long long dfs(long long x, long long fa) {
  long long now = 0;
  long long m1 = -1e17, m2 = -1e17;
  for (long long i = head[x]; i; i = nxt[i]) {
    long long y = ver[i];
    long long z = edge[i];
    if (y == fa) continue;
    long long sum = dfs(y, x) - z;
    if (sum > m1) {
      m2 = m1;
      m1 = sum;
    } else if (sum > m2) {
      m2 = sum;
    }
  }
  check_max(dp[x], m1 + a[x]);
  check_max(dp[x], a[x]);
  check_max(ans, dp[x]);
  check_max(ans, a[x] + m1 + m2);
  return dp[x];
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i < n; i++) {
    long long x, y, c;
    scanf("%lld%lld%lld", &x, &y, &c);
    add(x, y, c);
    add(y, x, c);
  }
  memset(dp, 0, sizeof(dp));
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
