#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
long long ans = 0;
long long dp[maxn];
struct node {
  int v;
  long long w;
} q;
bool cmp(long long i, long long j) { return i > j; }
vector<node> l[maxn];
int n;
int a[maxn];
void dfs(int x, int fa) {
  int i, v;
  vector<long long> s;
  dp[x] = a[x];
  ans = max(dp[x], ans);
  for (int i = 0; i < l[x].size(); i++)
    if (l[x][i].v != fa) {
      v = l[x][i].v;
      dfs(v, x);
      if (dp[v] > l[x][i].w) s.push_back(dp[v] - l[x][i].w);
    }
  if (s.size() == 0) return;
  if (s.size() == 1) {
    dp[x] += s[0];
    ans = max(ans, dp[x]);
    return;
  }
  sort(s.begin(), s.end(), cmp);
  dp[x] += s[0];
  ans = max(ans, dp[x] + s[1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int x;
  for (int i = 1; i < n; i++) {
    scanf("%d%d%lld", &x, &q.v, &q.w);
    l[x].push_back(q);
    swap(x, q.v);
    l[x].push_back(q);
  }
  dfs(1, 0);
  cout << ans;
  return 0;
}
