#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long, long long> > > adj;
long long dp[300009][3], w[300009];
void dfs(long long s, long long par) {
  long long second = 0;
  long long mx1 = -1, mx2 = -1;
  for (long long i = 0; i < adj[s].size(); i++) {
    if (adj[s][i].first != par) {
      dfs(adj[s][i].first, s);
      if (mx1 < dp[adj[s][i].first][0] - adj[s][i].second) {
        mx2 = mx1;
        mx1 = dp[adj[s][i].first][0] - adj[s][i].second;
      } else if (mx1 >= dp[adj[s][i].first][0] - adj[s][i].second &&
                 mx2 < dp[adj[s][i].first][0] - adj[s][i].second) {
        mx2 = dp[adj[s][i].first][0] - adj[s][i].second;
      }
    }
  }
  if (mx2 != -1 && mx1 != -1) {
    dp[s][0] = max(w[s], mx1 + w[s]);
    dp[s][1] = max(w[s], mx1 + mx2 + w[s]);
  }
  if (mx2 == -1 && mx1 != -1) {
    dp[s][0] = max(w[s], mx1 + w[s]);
    dp[s][1] = w[s];
  }
  if (mx2 == -1 && mx1 == -1) {
    dp[s][0] = max(dp[s][0], w[s]);
    dp[s][1] = max(dp[s][1], w[s]);
  }
}
int main() {
  long long n, i, u, v, c, ans = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> w[i];
  }
  adj.resize(n + 1);
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v >> c;
    adj[u].push_back(make_pair(v, c));
    adj[v].push_back(make_pair(u, c));
  }
  dfs(1, -1);
  for (i = 1; i <= n; i++) {
    ans = max({ans, dp[i][0], dp[i][1]});
  }
  cout << ans;
}
