#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 10;
const long long M = 1e9 + 7;
int n, x, y, z;
int last[N], to[2 * N], w[2 * N], num, nxt[2 * N];
long long a[N];
long long ans;
void Add(int u, int v, int c) {
  nxt[++num] = last[u];
  to[num] = v;
  w[num] = c;
  last[u] = num;
}
long long dp[N];
long long dfs(int u, int f) {
  long long max1, max2;
  max1 = max2 = 0;
  for (int i = last[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == f) continue;
    dfs(v, u);
    long long now = dp[v] - w[i];
    if (now >= max1) {
      max2 = max1;
      max1 = now;
    } else if (now > max2)
      max2 = now;
  }
  long long tot = max1 + max2 + a[u];
  ans = max(ans, tot);
  return dp[u] = max(max1, max2) + a[u];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", a + i);
  for (int i = 1; i <= n - 1; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    Add(x, y, z);
    Add(y, x, z);
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
