#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> g(300001);
long long int w[300001];
bool vis[300001] = {};
long long int dp[300001];
long long int ans = -1;
long long int dfs(int u) {
  vis[u] = 1;
  long long int maxm = w[u];
  long long int max1 = w[u], max2 = -1;
  for (auto &i : g[u]) {
    if (!vis[i.first]) {
      long long int temp = dfs(i.first);
      temp += (w[u] - i.second);
      maxm = ((maxm > temp) ? maxm : temp);
      if (max1 < temp) {
        max2 = max1;
        max1 = temp;
      } else if (max2 < temp) {
        max2 = temp;
      }
    }
  }
  ans = ((maxm > ans) ? (maxm > max1 + max2 - w[u]) ? maxm : max1 + max2 - w[u]
         : (ans > max1 + max2 - w[u]) ? ans
                                      : max1 + max2 - w[u]);
  return maxm;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int test = 1;
  while (test--) {
    long long int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> w[i];
    }
    for (int i = 1; i < n; i++) {
      dp[i] = -1;
      int x, y, z;
      cin >> x >> y >> z;
      g[x].push_back({y, z});
      g[y].push_back({x, z});
    }
    dp[n] = -1;
    dfs(1);
    cout << ans << endl;
  }
  return 0;
}
