#include <bits/stdc++.h>
using namespace std;
long long Set(long long n, long long pos) { return n | (1LL << pos); }
bool Check(long long n, long long pos) { return (bool)(n & (1LL << pos)); }
vector<long long> ed[300010], ct[300010];
long long ans;
long long a[300010];
long long sz[300010];
bool done[300010];
void dfs(long long n, long long p) {
  sz[n] = 1;
  for (long long i = 0; i < ed[n].size(); i++) {
    long long v = ed[n][i];
    if (v != p && done[v] == false) {
      dfs(v, n);
      sz[n] += sz[v];
    }
  }
}
long long adfs(long long n, long long p, long long h = 0) {
  h += a[n];
  long long ret = h;
  for (long long i = 0; i < ed[n].size(); i++) {
    long long v = ed[n][i];
    if (v != p && done[v] == false) {
      ret = max(ret, adfs(v, n, h - ct[n][i]));
    }
  }
  return ret;
}
long long decompose(long long cen) {
  dfs(cen, -1);
  long long target = sz[cen] / 2, p = -1;
  bool ok = false;
  while (!ok) {
    ok = true;
    for (long long i = 0; i < ed[cen].size(); i++) {
      long long v = ed[cen][i];
      if (p != v && done[v] == false && sz[v] > target) {
        ok = false;
        p = cen;
        cen = v;
      }
    }
  }
  long long mx1 = 0, mx2 = 0;
  done[cen] = true;
  for (long long i = 0; i < ed[cen].size(); i++) {
    long long v = ed[cen][i];
    if (!done[v]) {
      long long x = adfs(v, cen, -ct[cen][i]);
      if (x > mx1) {
        mx2 = mx1;
        mx1 = x;
      } else if (x > mx2) {
        mx2 = x;
      }
    }
  }
  ans = max(ans, mx1 + mx2 + a[cen]);
  for (long long i = 0; i < ed[cen].size(); i++) {
    long long v = ed[cen][i];
    if (!done[v]) {
      decompose(v);
    }
  }
  return cen;
}
int main() {
  long long t, i, j, n, m, u, v, cs, tmp, x, y, z;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i < n; i++) {
    scanf("%lld %lld %lld", &x, &y, &z);
    ed[y].push_back(x);
    ed[x].push_back(y);
    ct[y].push_back(z);
    ct[x].push_back(z);
  }
  decompose(1);
  cout << ans << endl;
  return 0;
}
