#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, m, s, a[1010], mi = 0x3f3f3f3f, an = 0;
vector<long long> ve(301010);
vector<vector<pair<long long, long long> > > gr(301010);
vector<long long> la(301010);
vector<long long> u(301010);
void dfs(long long st, int p = -1) {
  u[st] = true;
  long long cn = 0;
  la[st] = ve[st];
  vector<long long> cu;
  for (auto it : gr[st]) {
    if (!u[it.first]) {
      dfs(it.first, st);
      if (la[it.first] > it.second) {
        cu.push_back(la[it.first] - it.second);
      }
    }
  }
  sort(cu.begin(), cu.end());
  reverse(cu.begin(), cu.end());
  if (cu.size() > 1) {
    an = max(an, cu[0] + cu[1] + ve[st]);
  }
  if (cu.size()) {
    la[st] = max(la[st], cu[0] + ve[st]);
    an = max(an, la[st]);
  } else {
    la[st] = ve[st];
    an = max(an, la[st]);
  }
}
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ve[i];
  }
  for (i = 0; i < n - 1; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    gr[u].push_back({v, w});
    gr[v].push_back({u, w});
  }
  dfs(0);
  cout << an;
}
