#include <bits/stdc++.h>
using namespace std;
int const N = 300000;
vector<pair<int, int> > tr[N + 1];
int w[N + 1];
pair<long long, long long> go(int v = 1, int p = 0) {
  long long mx1 = 0, mx2 = 0, an = 0;
  for (int i = 0; i < (int)(tr[v].size()); ++i) {
    int u = tr[v][i].first;
    if (u == p) continue;
    pair<long long, long long> t = go(u, v);
    an = max(an, t.second);
    t.first -= tr[v][i].second;
    if (t.first > mx1)
      mx2 = mx1, mx1 = t.first;
    else if (t.first > mx2)
      mx2 = t.first;
  }
  an = max(an, mx1 + mx2 + w[v]);
  return make_pair(mx1 + w[v], an);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < (int)(n + 1); ++i) scanf("%d", w + i);
  for (int i = 1; i < (int)(n); ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    tr[a].push_back(make_pair(b, c));
    tr[b].push_back(make_pair(a, c));
  }
  printf("%lld\n", go().second);
}
