#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long dp1[300001], dp2[300001], w[300001];
vector<pair<long long, long long> > graph[300001];
void dfs1(long long node, long long parent) {
  dp1[node] = 0;
  for (auto x : graph[node]) {
    if (x.first == parent) continue;
    dfs1(x.first, node);
    if (dp1[x.first] >= x.second)
      dp1[node] = max(dp1[node], dp1[x.first] - x.second);
  }
  dp1[node] += w[node];
}
void dfs2(long long node, long long parent) {
  long long mx1 = 0, mx2 = 0;
  for (auto x : graph[node]) {
    if (x.first == parent) continue;
    if (dp1[x.first] - x.second + w[node] > mx1) {
      mx2 = mx1;
      mx1 = dp1[x.first] - x.second + w[node];
    } else if (dp1[x.first] - x.second + w[node] > mx2) {
      mx2 = dp1[x.first] - x.second + w[node];
    }
  }
  if (dp2[node] > mx1) {
    mx2 = mx1;
    mx1 = dp2[node];
  }
  if (dp2[node] > mx2) {
    mx2 = dp2[node];
  }
  for (auto x : graph[node]) {
    if (x.first == parent) continue;
    if (mx1 == dp1[x.first] - x.second + w[node]) {
      if (mx2 >= x.second) dp2[x.first] = mx2 - x.second + w[x.first];
    } else {
      if (mx1 >= x.second) dp2[x.first] = mx1 - x.second + w[x.first];
    }
    dp2[x.first] = max(dp2[x.first], w[x.first]);
    dfs2(x.first, node);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, n, i, j, k, ans = 0;
  cin >> n;
  for (i = 1; i < n + 1; i++) {
    cin >> w[i];
    dp1[i] = dp2[i] = 0;
  }
  for (i = 0; i < n - 1; i++) {
    cin >> j >> k >> t;
    graph[j].push_back({k, t});
    graph[k].push_back({j, t});
  }
  dfs1(1, 0);
  dp2[1] = w[1];
  dfs2(1, 0);
  for (i = 1; i < n + 1; i++) {
    ans = max(ans, dp1[i]);
    ans = max(ans, dp2[i]);
  }
  cout << ans;
}
