#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
int n, me = 0;
long long c[MAXN];
int head[MAXN], nxt[MAXN], to[MAXN], from[MAXN];
long long w[MAXN];
int v[MAXN], fa[MAXN];
long long tup[MAXN], tc[MAXN], tdown[MAXN];
int rt = 1;
void add_edge(int tf, int tt, long long tw) {
  ++me;
  from[me] = tf;
  to[me] = tt;
  w[me] = tw;
  nxt[me] = head[tf];
  head[tf] = me;
}
void dfs1(int x) {
  v[x] = 1;
  long long tmax = 0, tmaxid = 0, tmaxse = 0, tmaxseid = 0, tmp;
  for (int e = head[x]; e; e = nxt[e]) {
    int y = to[e];
    if (v[y]) {
      fa[x] = y;
      continue;
    }
    dfs1(y);
    tmp = max(tup[y] - w[e], (long long)0);
    if (tmp >= tmax) {
      tmaxseid = tmaxid;
      tmaxid = y;
      tmaxse = tmax;
      tmax = tmp;
    }
  }
  tmax += c[x];
  tmaxse += c[x];
  for (int e = head[x]; e; e = nxt[e]) {
    int y = to[e];
    if (y == fa[x]) continue;
    tmp = max(tup[y] - w[e], (long long)0);
    if (tmaxid && y != tmaxid) {
      tc[y] = max(tmax - w[e], (long long)0) + c[y];
    } else if (tmaxseid && y != tmaxseid) {
      tc[y] = max(tmaxse - w[e], (long long)0) + c[y];
    }
  }
  tup[x] = max(tmax, c[x]);
}
void dfs2(int x) {
  v[x] = 1;
  for (int e = head[x]; e; e = nxt[e]) {
    int y = to[e];
    if (v[y]) continue;
    tdown[y] = max(max(tdown[x] - w[e], (long long)0) + c[y], tc[y]);
    dfs2(y);
  }
}
int main() {
  scanf("%d", &n);
  int tf, tt;
  long long tw;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &c[i]);
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d%lld", &tf, &tt, &tw);
    add_edge(tf, tt, tw);
    add_edge(tt, tf, tw);
  }
  dfs1(rt);
  memset(v, 0, sizeof(v));
  dfs2(rt);
  long long gans = 0;
  for (int i = 1; i <= n; i++) {
    gans = max(gans, tup[i]);
    gans = max(gans, tdown[i]);
  }
  printf("%lld\n", gans);
  return 0;
}
