#include <bits/stdc++.h>
using namespace std;
const char DEBUG = 0;
const int VERTEX_ADD = 1000000;
mt19937 gen(
    (unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
#pragma GCC optimize("O3")
#pragma comment(linker, "/STACK:16777216")
struct edge {
  int v, w;
};
vector<edge> g[300000];
int n;
int w[300000];
long long dp[300000];
long long ans;
void dfs(int v, int p = -1) {
  for (edge& e : g[v])
    if (e.v != p) {
      dfs(e.v, v);
      if (dp[e.v] >= e.w) {
        ans = max(ans, dp[v] + dp[e.v] - e.w + w[v]);
        dp[v] = max(dp[v], dp[e.v] - e.w);
      }
    }
  dp[v] += w[v];
  ans = max(ans, dp[v]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 0; i < n - 1; i++) {
    int s, e, c;
    cin >> s >> e >> c;
    g[--s].push_back({--e, c});
    g[e].push_back({s, c});
  }
  dfs(0);
  cout << ans;
  return 0;
}
