#include <bits/stdc++.h>
using namespace std;
long long res[300009][3], ans = 0;
vector<pair<int, long long> > v[300009];
int arr[300009];
void dfs(int n, int p) {
  int i;
  res[n][0] = arr[n];
  for (i = 0; i < v[n].size(); i++) {
    int a = v[n][i].first;
    long long b = v[n][i].second;
    if (a - p) {
      dfs(a, n);
      long long k = res[a][1] - b;
      if (k) {
        if (res[n][1] < res[n][0] + k) {
          res[n][2] = res[n][1];
          res[n][1] = res[n][0] + k;
        } else if (res[n][2] < res[n][0] + k)
          res[n][2] = res[n][0] + k;
      }
    }
  }
  res[n][1] = max(res[n][1], res[n][0]);
  ans = max(ans,
            max(res[n][0], max(res[n][1], res[n][1] + res[n][2] - res[n][0])));
}
int main() {
  int n, a, b, i, c;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &arr[i + 1]);
  for (i = 1; i < n; i++) {
    scanf("%d %d %d", &a, &b, &c);
    v[a].push_back(make_pair(b, c));
    v[b].push_back(make_pair(a, c));
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
