#include <bits/stdc++.h>
using namespace std;
const int maxn = 300007;
int e1, head[maxn], to[maxn << 1], w[maxn << 1], next1[maxn << 1], v[maxn];
long long dp[maxn];
long long ans;
void addedge(int u, int v, int w1) {
  ++e1;
  next1[e1] = head[u];
  head[u] = e1;
  to[e1] = v;
  w[e1] = w1;
}
void dfs(int u, int fa) {
  long long w1 = 0, w2 = 0;
  for (int i = head[u]; i; i = next1[i]) {
    int v = to[i];
    if (v != fa) {
      dfs(v, u);
      if (dp[v] - w[i] > w1)
        w2 = max(w2, w1), w1 = dp[v] - w[i];
      else
        w2 = max(w2, dp[v] - w[i]);
    }
  }
  ans = max(ans, w1 + w2 + v[u]);
  dp[u] = w1 + v[u];
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
  }
  for (int i = 1; i < n; i++) {
    int u, v, w1;
    scanf("%d%d%d", &u, &v, &w1);
    addedge(u, v, w1);
    addedge(v, u, w1);
  }
  dfs(1, 0);
  cout << ans;
  return 0;
}
