#include <bits/stdc++.h>
using namespace std;
const int sz = 3e5 + 100;
vector<pair<long long int, long long int> > ad[sz];
long long int dp[sz];
long long int ara[sz];
long long int ans = 0;
void DFS(long long int p, long long int par) {
  dp[p] = ara[p];
  for (auto xx : ad[p]) {
    if (xx.first != par) {
      DFS(xx.first, p);
      dp[p] = max(dp[p], ara[p] + dp[xx.first] - xx.second);
    }
  }
}
void DFS1(long long int p, long long int par, long long int prev) {
  prev += ara[p];
  ans = max(ans, prev);
  ans = max(ans, dp[p]);
  long long int mx1 = 0, mx2 = 0;
  long long int id1, id2;
  id1 = -1, id2 = -1;
  for (auto xx : ad[p]) {
    if (xx.first != par) {
      long long int tk = dp[xx.first] - xx.second;
      ans = max(ans, prev + dp[xx.first] - xx.second);
      if (tk > mx1) {
        mx2 = mx1, id2 = id1;
        mx1 = tk, id1 = xx.first;
      } else if (tk > mx2)
        mx2 = tk, id2 = xx.first;
    }
  }
  ans = max(ans, mx1 + mx2 + ara[p]);
  for (auto xx : ad[p]) {
    if (xx.first != par) {
      if (xx.first == id1) {
        long long int tk = 0ll;
        tk = max(tk, max(prev - xx.second, mx2 + ara[p] - xx.second));
        DFS1(xx.first, p, tk);
      } else {
        long long int tk = 0ll;
        tk = max(tk, max(prev - xx.second, mx1 + ara[p] - xx.second));
        DFS1(xx.first, p, tk);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int a, b, c, i, j, k, q, p, x, y, ct, ct1, m, l, r, x1, y1, h, sum1,
      in, z, mid, n, mx;
  char ch;
  long long int d;
  string str1, str2, str;
  bool bl, bl1;
  int t, cs = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ara[i];
  for (int i = 1; i < n; i++) {
    cin >> p >> q >> x;
    ad[p].push_back({q, x});
    ad[q].push_back({p, x});
  }
  DFS(1, -1);
  DFS1(1, -1, 0);
  cout << ans << '\n';
}
