#include <bits/stdc++.h>
using namespace std;
const int duzo = 300007;
const long long inf = 1e16;
vector<pair<int, long long> > g[duzo];
long long w[duzo];
long long gz;
bool odw[duzo];
long long dfs(int wie = 1, long long dost = 0) {
  odw[wie] = true;
  long long best1 = -inf, best2 = -inf;
  for (auto x : g[wie]) {
    if (!odw[x.first]) {
      long long ret = dfs(x.first, dost + w[x.first] - x.second);
      if (ret >= best1) {
        best2 = best1;
        best1 = ret;
      } else if (ret >= best2)
        best2 = ret;
    }
  }
  if (0)
    cout << "wie: " << wie << " best1: " << best1 << " best2: " << best2
         << " dost: " << dost << "\n";
  gz = max(gz, best1 + best2 - 2ll * dost + w[wie]);
  gz = max(gz, best1 + w[wie] - dost);
  return max(dost, max(best1, best2));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> w[i];
    gz = max(gz, w[i]);
  }
  for (int i = 1; i < n; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    g[u].push_back({v, c});
    g[v].push_back({u, c});
  }
  dfs();
  cout << gz;
  return 0;
}
