#include <bits/stdc++.h>
using namespace std;
string to_string(bool x) { return x ? "true" : "false"; }
string to_string(char x) { return string(1, x); }
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
using ll = long long;
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using vi = vector<ll>;
using vll = vector<ll>;
using vvi = vector<vector<ll> >;
using vpii = vector<pii>;
using ld = long double;
using vs = vector<string>;
ll N;
vi W;
vvi dp;
vector<vpii> G;
void dfs(ll v, ll p = -1) {
  vi sons;
  dp[v][0] = dp[v][1] = W[v];
  for (auto e : G[v]) {
    ll to = e.first;
    ll cc = e.second;
    if (to == p) continue;
    dfs(to, v);
    sons.push_back(dp[to][0] - cc);
  }
  sort((sons).begin(), (sons).end());
  reverse((sons).begin(), (sons).end());
  if ((ll)(sons).size() > 0) dp[v][0] = max(dp[v][0], sons[0] + W[v]);
  if ((ll)(sons).size() > 1) dp[v][1] = max(dp[v][1], sons[0] + sons[1] + W[v]);
}
void solve() {
  cin >> N;
  W.resize(N);
  dp.resize(N, vi(2));
  for (auto &w : W) cin >> w;
  G.resize(N);
  for (ll i = 0; i < N - 1; i++) {
    ll u, v, c;
    cin >> u >> v >> c;
    --u, --v;
    G[u].push_back({v, c});
    G[v].push_back({u, c});
  }
  dfs(0);
  ll ans = 0;
  42;
  for (ll v = 0; v < N; v++) ans = max({ans, dp[v][0], dp[v][1]});
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed | ios::showpoint);
  cout.precision(12);
  cerr.setf(ios::fixed | ios::showpoint);
  cerr.precision(4);
  solve();
  return 0;
}
