#include <bits/stdc++.h>
using namespace std;
struct gan {
  long long to, cost;
};
struct di {
  long long loc, p;
};
struct item {
  long long cur, parent, cost;
};
long long gg[300001];
struct di dp[3][300001];
vector<struct gan> con[300001];
queue<struct item> Q;
void do_bfs(long long s);
long long dfs(long long cur, long long parent);
long long vali(long long a, long long b);
int main(void) {
  long long n, a, b, c, ans = 0;
  struct gan I;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", gg + i);
  for (long long i = 0; i < n - 1; i++) {
    scanf("%lld%lld%lld", &a, &b, &c);
    I.to = b;
    I.cost = c;
    con[a].push_back(I);
    I.to = a;
    I.cost = c;
    con[b].push_back(I);
  }
  dfs(1, -1);
  do_bfs(1);
  for (long long i = 1; i <= n; i++) {
    ans = max(ans, dp[0][i].p);
    ans = max(ans, dp[1][i].p);
    ans = max(ans, dp[2][i].p);
  }
  printf("%lld\n", ans);
}
void do_bfs(long long s) {
  struct item I, C;
  long long next, r;
  I.cur = s;
  I.parent = -1;
  I.cost = gg[s];
  Q.push(I);
  while (!Q.empty()) {
    C = Q.front();
    Q.pop();
    for (long long i = 0; i < con[C.cur].size(); i++) {
      next = con[C.cur][i].to;
      if (next == C.parent) continue;
      if (C.parent == -1) {
        r = vali(C.cur, next);
        r = r + gg[next] - con[C.cur][i].cost;
        dp[2][next].p = r;
      } else {
        r = vali(C.cur, next);
        r = max(dp[2][C.cur].p, r);
        r = r + gg[next] - con[C.cur][i].cost;
        dp[2][next].p = r;
      }
      I.parent = C.cur;
      I.cur = next;
      I.cost = con[C.cur][i].cost;
      Q.push(I);
    }
  }
}
long long vali(long long a, long long b) {
  if (dp[0][a].loc != b) return dp[0][a].p;
  return dp[1][a].p;
}
long long dfs(long long cur, long long parent) {
  long long next, r, mmx = gg[cur];
  dp[0][cur].p = gg[cur];
  dp[0][cur].loc = cur;
  for (long long i = 0; i < con[cur].size(); i++) {
    next = con[cur][i].to;
    if (next == parent) continue;
    r = gg[cur] + dfs(next, cur) - con[cur][i].cost;
    if (r > dp[0][cur].p) {
      mmx = r;
      dp[1][cur] = dp[0][cur];
      dp[0][cur].p = r;
      dp[0][cur].loc = next;
    } else if (r > dp[1][cur].p) {
      mmx = r;
      dp[1][cur].p = r;
      dp[1][cur].loc = next;
    }
  }
  return dp[0][cur].p;
}
