#include <bits/stdc++.h>
using namespace std;
int n;
long long w[300005];
vector<pair<int, long long> > gr[300005];
long long dp[300005];
vector<long long> v[300005];
long long go(int now, int par) {
  dp[now] = w[now];
  for (auto to : gr[now]) {
    if (to.first == par) continue;
    long long xxx = max(0LL, go(to.first, now) - to.second);
    v[now].push_back(xxx);
  }
  if (v[now].size() == 0) return dp[now];
  sort(v[now].begin(), v[now].end());
  if (v[now].size() >= 2) {
    dp[now] = w[now] + v[now][v[now].size() - 1] + v[now][v[now].size() - 2];
  } else
    dp[now] = w[now] + v[now][0];
  return v[now][v[now].size() - 1] + w[now];
}
int main() {
  int i, j;
  long long ans = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &w[i]);
    ans = max(ans, w[i]);
  }
  for (i = 1; i < n; i++) {
    int u, v, c;
    scanf("%d", &u);
    scanf("%d", &v);
    scanf("%d", &c);
    gr[u].push_back({v, c});
    gr[v].push_back({u, c});
  }
  go(1, -1);
  for (i = 1; i <= n; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}
