#include <bits/stdc++.h>
using namespace std;
const int mx = 5e5 + 3;
long long a[mx], dp[mx], ans;
vector<pair<int, int> > g[mx];
void dfs(int u, int p) {
  dp[u] = a[u];
  ans = max(ans, dp[u]);
  for (int i = 0; i < g[u].size(); i++) {
    pair<int, int> v = g[u][i];
    if (v.first != p) {
      dfs(v.first, u);
      long long c = dp[v.first] - v.second;
      ans = max(ans, c + dp[u]);
      dp[u] = max(dp[u], c + a[u]);
    }
  }
}
int main() {
  long long n, i, j, u, v, w;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i < n; i++) {
    cin >> u >> v >> w;
    g[u].push_back(pair<int, int>(v, w));
    g[v].push_back(pair<int, int>(u, w));
  }
  dfs(1, 0);
  cout << ans << endl;
  return 0;
}
