#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300100;
int n, p[MAXN];
vector<pair<int, int> > v[MAXN];
long long dp[MAXN];
vector<pair<long long, int> > v1[MAXN];
long long dp_up[MAXN];
int bio[MAXN];
int P[MAXN];
int C[MAXN];
void dfs(int cvor, int par) {
  P[cvor] = par;
  dp[cvor] = p[cvor];
  for (int i = (0); i < int((int)v[cvor].size()); i++) {
    int ncvor = v[cvor][i].first;
    if (ncvor == par) continue;
    dfs(ncvor, cvor);
    C[ncvor] = v[cvor][i].second;
    dp[cvor] = max(dp[cvor], p[cvor] + dp[ncvor] - v[cvor][i].second);
    v1[cvor].push_back({dp[ncvor] + p[cvor] - v[cvor][i].second, ncvor});
  }
  sort((v1[cvor]).begin(), (v1[cvor]).end());
  reverse((v1[cvor]).begin(), (v1[cvor]).end());
}
void up(int cvor) {
  bio[cvor] = 1;
  dp_up[cvor] = p[cvor];
  if (cvor == 0) return;
  int ncvor = P[cvor];
  if (!bio[ncvor]) up(ncvor);
  long long ret = dp_up[ncvor];
  for (int i = (0); i < int((int)v1[ncvor].size()); i++) {
    if (v1[ncvor][i].second != cvor) {
      ret = max(ret, v1[ncvor][i].first);
      break;
    }
  }
  dp_up[cvor] = max(dp_up[cvor], ret + p[cvor] - C[cvor]);
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < int(n); i++) scanf("%d", &p[i]);
  for (int i = (0); i < int(n - 1); i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a--;
    b--;
    v[a].push_back(make_pair(b, c));
    v[b].push_back({a, c});
  }
  dfs(0, -1);
  for (int i = (0); i < int(n); i++)
    if (!bio[i]) up(i);
  long long sol = 0;
  for (int i = (0); i < int(n); i++) sol = max(sol, max(dp[i], dp_up[i]));
  cout << sol << endl;
  return 0;
}
