#include <bits/stdc++.h>
using namespace std;
long long ans;
vector<long long> w;
vector<vector<pair<long long, long long>>> g;
vector<long long> dp;
void dfs(int v, int pred = -1) {
  dp[v] = w[v];
  long long max1 = 0, max2 = 0;
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i].first == pred) continue;
    dfs(g[v][i].first, v);
    if (dp[g[v][i].first] - g[v][i].second >= 0) {
      dp[v] = max(dp[v], dp[g[v][i].first] - g[v][i].second + w[v]);
      max2 = max(max2, dp[g[v][i].first] - g[v][i].second);
    }
    if (max1 < max2) {
      swap(max1, max2);
    }
  }
  ans = max(ans, max1 + max2 + w[v]);
}
int main() {
  int n;
  cin >> n;
  w.resize(n);
  g.resize(n);
  dp.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  for (int i = 0; i < n - 1; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
  }
  dfs(0);
  cout << ans;
  return 0;
}
