#include <bits/stdc++.h>
using namespace std;
int n;
long long wn[300005];
long long re = 0;
std::vector<pair<int, int> > tos[300005];
long long dfs(int last, int nod) {
  long long j = 0;
  long long lmax = 0;
  for (std::vector<pair<int, int> >::iterator i = tos[nod].begin();
       i != tos[nod].end(); ++i) {
    if ((i->first) == last) {
      continue;
    }
    long long t = dfs(nod, i->first) - (i->second);
    re = max(re, lmax + t + wn[nod]);
    lmax = max(lmax, t);
    j = max(j, t);
  }
  j += wn[nod];
  re = max(re, j);
  return j;
}
int main(int argc, char const *argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", wn + i);
    re = max(re, wn[i]);
  }
  int u, v, c;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d%d%d", &u, &v, &c);
    tos[u].push_back(make_pair(v, c));
    tos[v].push_back(make_pair(u, c));
  }
  dfs(0, 1);
  printf("%lld\n", re);
  return 0;
}
