#include <bits/stdc++.h>
using namespace std;
const long long Max = 3e5 + 1;
void nos() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
}
long long n;
long long w[Max];
vector<pair<long long, long long> > v[Max];
void read() {
  cin >> n;
  long long i;
  for (i = 1; i <= n; i++) cin >> w[i];
  for (i = 1; i < n; i++) {
    long long n1, n2, cost;
    cin >> n1 >> n2 >> cost;
    cost *= -1;
    v[n1].push_back({n2, cost});
    v[n2].push_back({n1, cost});
  }
}
long long dp[Max];
long long viz[Max];
vector<pair<long long, long long> > child[Max];
void dfs(long long nod, long long edge) {
  if (viz[nod] == 0) {
    viz[nod] = 1;
    long long best_child = 0;
    for (auto vec : v[nod])
      if (viz[vec.first] == 0) {
        dfs(vec.first, vec.second);
        child[nod].push_back({vec.first, vec.second});
        best_child = max(best_child, dp[vec.first]);
      }
    dp[nod] = max(best_child + edge + w[nod], 0LL);
  }
}
long long best;
bool cmp(long long a, long long b) { return a > b; }
void teste(long long nod) {
  long long this_ans = 0;
  vector<long long> copii;
  for (auto vec : child[nod]) {
    long long val_child = dp[vec.first];
    copii.push_back(val_child);
  }
  sort(copii.begin(), copii.end(), cmp);
  this_ans = w[nod];
  if (!copii.empty()) this_ans = max(this_ans, copii[0] + w[nod]);
  if (copii.size() >= 2) {
    long long compo = w[nod] + copii[0] + copii[1];
    this_ans = max(this_ans, compo);
  }
  best = max(best, this_ans);
}
void solve() {
  v[0].push_back({1, 0});
  dfs(0, 0);
  long long i;
  for (i = 0; i <= n; i++) teste(i);
  cout << best;
}
int32_t main() {
  nos();
  read();
  solve();
  return 0;
}
