#include <bits/stdc++.h>
using namespace std;
const int max_n = 3 * 1e5 + 1;
int n;
long long w[max_n], d[max_n];
long long ans;
vector<pair<long long, long long>> tree[max_n];
void dfs(int here, int parent) {
  long long maxi = 0, maxj = 0, val = 0;
  d[here] = w[here];
  for (int i = 0; i < tree[here].size(); i++) {
    int nxt = tree[here][i].first;
    int cost = tree[here][i].second;
    if (nxt == parent) continue;
    dfs(nxt, here);
    d[here] = max(d[here], d[nxt] + w[here] - cost);
    val = d[nxt] - cost;
    if (val > maxi) {
      maxj = maxi;
      maxi = val;
    } else
      maxj = max(maxj, val);
    ans = max(ans, d[here]);
  }
  ans = max(ans, maxi + maxj + w[here]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 0; i < n - 1; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    tree[u].push_back({v, c});
    tree[v].push_back({u, c});
  }
  dfs(1, 1);
  cout << ans;
}
