#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long MAXN = 3e5 + 69;
const long long INF = 1e9 + 85;
long long n, arr[MAXN], ans[MAXN], dp[MAXN];
vector<long long> pathmax[MAXN];
vector<pair<long long, long long>> g[MAXN];
void dfs(long long v, long long parent = -1) {
  for (auto u : g[v]) {
    long long child = u.first, weight = u.second;
    if (child != parent) {
      dfs(child, v);
      dp[v] = max(dp[v], dp[child] - weight + arr[v]),
      ans[v] = max(ans[v], ans[child]),
      pathmax[v].push_back(dp[child] - weight);
    }
  }
  ans[v] = max(ans[v], dp[v]);
  if (pathmax[v].size() < 2) return;
  sort(pathmax[v].begin(), pathmax[v].end());
  reverse(pathmax[v].begin(), pathmax[v].end());
  ans[v] = max(ans[v], pathmax[v][0] + pathmax[v][1] + arr[v]);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long v, u, w;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> arr[i], dp[i] = arr[i];
  for (long long i = 1; i < n; i++)
    cin >> v >> u >> w, g[v].push_back({u, w}), g[u].push_back({v, w});
  dfs(1);
  cout << ans[1] << "\n";
}
