#include <bits/stdc++.h>
using namespace std;
struct node {
  int v;
  long long c;
};
struct vx {
  int id, fa, dep;
  long long flen;
};
vx f[310000];
vector<node> v[310000];
long long w[310000];
priority_queue<long long, vector<long long>, less<long long> > q[310000];
void dfs(int x) {
  int i;
  for (i = 0; i < v[x].size(); ++i) {
    if (f[v[x][i].v].fa == 0) {
      f[v[x][i].v].fa = x;
      f[v[x][i].v].dep = f[x].dep + 1;
      f[v[x][i].v].flen = v[x][i].c;
      dfs(v[x][i].v);
    }
  }
}
bool cmp(vx x, vx y) { return x.dep > y.dep; }
int main() {
  int i, j, n, u, vv;
  long long c;
  long long a1, a2;
  long long ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%I64d", &w[i]);
  for (i = 1; i < n; ++i) {
    node r;
    scanf("%d%d%I64d", &u, &vv, &c);
    r.v = vv;
    r.c = c;
    v[u].push_back(r);
    r.v = u;
    v[vv].push_back(r);
  }
  for (i = 1; i <= n; ++i) f[i].id = i;
  f[1].dep = 1;
  dfs(1);
  sort(f + 1, f + 1 + n, cmp);
  for (i = 1; i < n; ++i) {
    u = f[i].id;
    if (!q[u].empty()) {
      if (q[u].top() - f[i].flen + w[u] > 0)
        q[f[i].fa].push(q[u].top() - f[i].flen + w[u]);
    } else if (-f[i].flen + w[u] > 0)
      q[f[i].fa].push(-f[i].flen + w[u]);
  }
  for (i = 1; i <= n; ++i) {
    a1 = a2 = 0;
    if (!q[i].empty()) {
      a1 = q[i].top();
      q[i].pop();
    }
    if (!q[i].empty()) {
      a2 = q[i].top();
      q[i].pop();
    }
    if (a1 + a2 + w[i] > ans) ans = a1 + a2 + w[i];
  }
  printf("%I64d", ans);
  return 0;
}
