#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
long long w[300005];
vector<pair<long long, long long> > g[300005];
long long ans = 0;
long long val[300004];
long long par[300005];
void dfs(long long x, long long p) {
  par[x] = p;
  vector<long long> v;
  val[x] = w[x];
  long long z = 0;
  for (auto i : g[x]) {
    if (i.first != p) {
      dfs(i.first, x);
      z = max(z, val[i.first] - i.second);
    }
  }
  val[x] += z;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> w[i];
  for (long long i = 0; i < n - 1; i++) {
    long long x, y, l;
    cin >> x >> y >> l;
    g[x].push_back({y, l});
    g[y].push_back({x, l});
  }
  dfs(1, -1);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans = max(ans, val[i]);
    vector<long long> v;
    for (auto j : g[i]) {
      if (j.first != par[i]) {
        v.push_back(val[j.first] - j.second);
      }
    }
    sort(v.begin(), v.end());
    if (v.size() > 1) {
      ans = max(ans, val[i] + v[v.size() - 2]);
    }
  }
  cout << ans << "\n";
}
