#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> w(n + 1);
  for (long long i = 1; i <= n; i++) {
    cin >> w[i];
  }
  vector<vector<pair<long long, long long>>> adj(n + 1);
  vector<long long> dp(n + 1);
  for (long long i = 0; i < n - 1; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    adj[u].push_back({v, c});
    adj[v].push_back({u, c});
  }
  long long ans = 0;
  function<void(long long, long long)> dfs = [&](long long v, long long par) {
    for (auto it : adj[v]) {
      if (it.first == par) continue;
      dfs(it.first, v);
      ans = max(ans, dp[it.first] + w[v] - it.second);
    }
    priority_queue<long long> pq;
    for (auto it : adj[v]) {
      if (it.first != par) {
        pq.push(dp[it.first] - it.second);
      }
    }
    long long big1 = 0, big2 = 0;
    while (!pq.empty()) {
      long long ora = pq.top();
      pq.pop();
      if (big1 == 0 && ora > 0) {
        big1 = ora;
      } else if (big2 == 0 && ora > 0) {
        big2 = ora;
      }
    }
    ans = max(ans, big1 + big2 + w[v]);
    dp[v] += big1;
    dp[v] += w[v];
    ans = max(ans, dp[v]);
  };
  dfs(1, -1);
  cout << ans << '\n';
}
