#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000;
int w[MAXN];
vector<pair<int, int> > g[MAXN];
bool was[MAXN];
pair<long long, long long> dfs(int v) {
  long long ans = w[v];
  long long max_len = w[v];
  was[v] = 1;
  long long best[2] = {0, 0};
  for (auto u : g[v]) {
    if (!was[u.first]) {
      pair<long long, long long> cur_ans = dfs(u.first);
      ans = max(ans, cur_ans.first);
      cur_ans.second -= u.second;
      max_len = max(max_len, cur_ans.second + w[v]);
      if (best[0] < cur_ans.second) {
        best[1] = best[0];
        best[0] = cur_ans.second;
      } else {
        if (best[1] < cur_ans.second) {
          best[1] = cur_ans.second;
        }
      }
    }
  }
  ans = max(ans, best[1] + best[0] + w[v]);
  return {ans, max_len};
}
int main(int argc, const char* argv[]) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%i", w + i);
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v, c;
    scanf("%i %i %i", &u, &v, &c);
    u--;
    v--;
    g[u].push_back({v, c});
    g[v].push_back({u, c});
  }
  pair<long long, long long> ans = dfs(0);
  cout << ans.first << endl;
  return 0;
}
