#include <bits/stdc++.h>
using namespace std;
vector<pair<long int, long long int> > vect[300001];
vector<long long int> ane[300001];
long long int val[300001];
long long int ans;
long long int fn(long int x, long int y) {
  long int sz = vect[x].size();
  long long int tmp = val[x];
  for (long int i = 0; i < sz; ++i) {
    if (vect[x][i].first == y) continue;
    long long int t = fn(vect[x][i].first, x) - vect[x][i].second;
    ane[x].push_back(t);
    tmp = max(tmp, t + val[x]);
  }
  ans = max(ans, tmp);
  sort(ane[x].begin(), ane[x].end(), greater<long long int>());
  sz = (x == y) ? sz : sz - 1;
  if (sz >= 2) {
    long long int tmp1 = ane[x][0];
    long long int tmp2 = ane[x][1];
    if (tmp1 >= 0) {
      tmp1 += val[x];
      tmp1 += tmp2;
      ans = max(ans, tmp1);
    }
  }
  return tmp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long int n;
  cin >> n;
  for (long int i = 1; i <= n; ++i) cin >> val[i];
  long int x, y, z;
  for (long int i = 1; i < n; ++i) {
    cin >> x >> y >> z;
    vect[x].push_back(make_pair(y, z));
    vect[y].push_back(make_pair(x, z));
  }
  ans = 0;
  long long int tmp = fn(1, 1);
  cout << ans;
  return 0;
}
