#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
const long long MOD = 1e9 + 7;
long long w[300100];
vector<pair<int, int>> adj[300100];
long long dfs(int u, int pr, long long &ans) {
  ans = max(ans, w[u]);
  long long mx1 = 0, mx2 = 0;
  for (auto &p : adj[u])
    if (p.first != pr) {
      long long t = dfs(p.first, u, ans) - p.second;
      if (mx1 < t)
        mx2 = mx1, mx1 = t;
      else
        mx2 = max(mx2, t);
    }
  ans = max(ans, mx1 + mx2 + w[u]);
  return mx1 + w[u];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(20);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    int c;
    cin >> c;
    u--, v--;
    adj[u].push_back({v, c});
    adj[v].push_back({u, c});
  }
  long long ans = 0;
  dfs(0, -1, ans);
  cout << ans << '\n';
  return 0;
}
