#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 3e5 + 7;
int cnt;
int nxt[maxn * 2], head[maxn], to[maxn * 2];
long long w[maxn], e[maxn * 2];
long long dp[maxn][2];
long long ans = 0;
void add(int u, int v, long long c) {
  ++cnt;
  to[cnt] = v;
  e[cnt] = c;
  nxt[cnt] = head[u];
  head[u] = cnt;
}
void dp_rule(int u, int fa) {
  long long max1 = 0, max2 = 0;
  for (int i = head[u]; i; i = nxt[i]) {
    if (to[i] == fa) continue;
    int v = to[i];
    dp_rule(v, u);
    if (dp[v][0] - e[i] >= max1) {
      max2 = max1;
      max1 = dp[v][0] - e[i];
    } else if (dp[v][0] - e[i] > max2) {
      max2 = dp[v][0] - e[i];
    }
  }
  dp[u][0] = max1 + w[u];
  dp[u][1] = max1 + max2 + w[u];
  ans = max(ans, max(dp[u][0], dp[u][1]));
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &w[i]);
  }
  int u, v;
  long long c;
  for (int i = 1; i < n; i++) {
    scanf("%d%d%I64d", &u, &v, &c);
    add(u, v, c);
    add(v, u, c);
  }
  dp_rule(1, 0);
  printf("%I64d\n", ans);
  return 0;
}
