#include <bits/stdc++.h>
using namespace std;
struct node {
  long long a, sum;
} t, tt;
vector<node> vec[300005];
long long cost[300005], in[300005], dp[300005][2], vis[300005];
queue<node> que;
int main(void) {
  long long i, j, n, m, a, b, c;
  long long ans;
  scanf("%lld", &n);
  ans = 0;
  for (i = 1; i <= n; i++) {
    scanf("%lld", &cost[i]);
    ans = max(ans, cost[i]);
  }
  for (i = 1; i < n; i++) {
    scanf("%lld %lld %lld", &a, &b, &c);
    in[a]++;
    in[b]++;
    t.sum = c;
    t.a = b;
    vec[a].push_back(t);
    t.a = a;
    vec[b].push_back(t);
  }
  for (i = 1; i <= n; i++) {
    if (in[i] == 1) {
      t.a = i;
      t.sum = cost[i];
      que.push(t);
      in[i]--;
    }
  }
  while (que.size()) {
    t = que.front();
    ans = max(ans, t.sum);
    vis[t.a] = 1;
    que.pop();
    for (auto x : vec[t.a]) {
      if (vis[x.a] == 1) {
        continue;
      } else {
        if (dp[x.a][0] < t.sum - x.sum) {
          dp[x.a][1] = dp[x.a][0];
          dp[x.a][0] = t.sum - x.sum;
        } else if (dp[x.a][1] < t.sum - x.sum) {
          dp[x.a][1] = t.sum - x.sum;
        }
        ans = max(ans, dp[x.a][0] + dp[x.a][1] + cost[x.a]);
        in[x.a]--;
        if (in[x.a] == 1) {
          tt.a = x.a;
          tt.sum = dp[x.a][0] + cost[x.a];
          que.push(tt);
        }
      }
    }
  }
  printf("%lld\n", ans);
}
