#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
struct node {
  long long val, w;
};
vector<node> q[N];
long long n;
long long ans;
long long dp[N];
long long a[N];
void dfs(long long u, long long fa) {
  dp[u] = a[u];
  if (ans < a[u]) ans = a[u];
  for (int i = 0; i < q[u].size(); i++) {
    node v = q[u][i];
    if (v.w == fa) continue;
    dfs(v.w, u);
    ans = max(ans, (long long)dp[u] + dp[v.w] - v.val);
    dp[u] = max(dp[u], dp[v.w] + a[u] - v.val);
  }
}
int w[N];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 2; i <= n; i++) {
    int u, v, val;
    scanf("%lld %lld %lld", &u, &v, &val);
    node pi;
    pi.val = val;
    pi.w = v;
    node as;
    as.val = val;
    as.w = u;
    q[u].push_back(pi);
    q[v].push_back(as);
  }
  dfs(1, -1);
  printf("%lld\n", ans);
}
