#include <bits/stdc++.h>
using namespace std;
string char_to_str(char c) {
  string tem(1, c);
  return tem;
}
long long maxx = 0;
long long ans(long long i, long long pr,
              vector<pair<long long, long long>> gr[], long long a[]) {
  long long ma = a[i];
  vector<long long> v;
  for (auto r : gr[i]) {
    if (r.first != pr) v.push_back(ans(r.first, i, gr, a) - r.second);
  }
  sort(v.begin(), v.end(), greater<long long>());
  if (v.size() == 0) {
    maxx = max(ma, maxx);
    return ma;
  }
  if (v.size() == 1) {
    if (v[0] >= 0) {
      maxx = max(maxx, ma + v[0]);
      return (ma + v[0]);
    }
  }
  if (v[0] >= 0 && v[1] >= 0) {
    maxx = max(maxx, ma + v[0] + v[1]);
    return ma + v[0];
  }
  maxx = max(maxx, (ma + max(0ll, v[0])));
  return (ma + max(0ll, v[0]));
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long a[n + 1];
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  vector<pair<long long, long long>> gr[n + 1];
  for (long long i = 0; i < n - 1; ++i) {
    long long x, y, w;
    cin >> x >> y >> w;
    gr[x].push_back({y, w});
    gr[y].push_back({x, w});
  }
  ans(1, -1, gr, a);
  cout << maxx;
}
