#include <bits/stdc++.h>
using namespace std;
int n, v[300002];
vector<pair<int, int> > adj[300002];
long long bst[300002];
long long ans;
void dfs(int nod) {
  bst[nod] = 0;
  long long bst2 = 0;
  for (pair<int, int> e : adj[nod]) {
    int son = e.first, c = e.second;
    if (bst[son] == -1) {
      dfs(son);
      long long crt = bst[son] + v[nod] - c;
      if (bst[nod] <= crt) {
        bst2 = bst[nod];
        bst[nod] = crt;
      } else if (crt > bst2)
        bst2 = crt;
    }
  }
  ans = max(ans, max(bst[nod], bst[nod] + bst2 - v[nod]));
  bst[nod] = max(bst[nod], 1LL * v[nod]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &v[i]);
    bst[i] = -1;
    ans = max(ans, 1LL * v[i]);
  }
  for (int i = 1; i < n; ++i) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    adj[u].push_back(pair<int, int>{v, c});
    adj[v].push_back(pair<int, int>{u, c});
  }
  dfs(1);
  printf("%lld\n", ans);
  return 0;
}
