#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &item) {
  out << '(' << item.first << ", " << item.second << ')';
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  for (const auto &item : v) out << item << ' ';
  return out;
}
int ch[300010];
ll ans;
ll w[300010], bst[300010];
vector<pii> adj[300010];
void dfs(int v, int p = -1) {
  bst[v] = w[v];
  ch[v] = -1;
  for (auto e : adj[v])
    if (e.first != p) {
      dfs(e.first, v);
      if (bst[e.first] > e.second && bst[v] < bst[e.first] - e.second + w[v]) {
        bst[v] = bst[e.first] - e.second + w[v];
        ch[v] = e.first;
      }
    }
}
void recalculate(int v, int p) {
  bst[v] = w[v];
  ch[v] = -1;
  for (auto e : adj[v])
    if (e.first != p) {
      if (bst[e.first] > e.second && bst[v] < bst[e.first] - e.second + w[v]) {
        bst[v] = bst[e.first] - e.second + w[v];
        ch[v] = e.first;
      }
    }
}
void solve(int v, int p = -1) {
  ans = max(ans, bst[v]);
  for (auto e : adj[v])
    if (e.first != p) {
      ll vCurrBst = bst[v];
      int vCurrCh = ch[v];
      ll uCurrBst = bst[e.first];
      int uCurrCh = ch[e.first];
      if (ch[v] == e.first) recalculate(v, e.first);
      if (bst[v] > e.second && bst[e.first] < bst[v] - e.second + w[e.first]) {
        bst[e.first] = bst[v] - e.second + w[e.first];
        ch[e.first] = v;
      }
      solve(e.first, v);
      bst[v] = vCurrBst;
      ch[v] = vCurrCh;
      bst[e.first] = uCurrBst;
      ch[e.first] = uCurrCh;
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  int i, n, a, b, c;
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> w[i];
  for (i = 1; i < n; ++i) {
    cin >> a >> b >> c;
    adj[a].push_back({b, c});
    adj[b].push_back({a, c});
  }
  dfs(1);
  solve(1);
  cout << ans << '\n';
  return 0;
}
