#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int e[N << 1], ne[N << 1], h[N << 1], idx, w[N << 1];
long long a[N];
long long dp[N], ans;
void init() {
  memset(h, -1, sizeof h);
  idx = 0;
}
void add(int a, int b, int c) {
  e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx++;
}
void dfs(int x, int pre) {
  dp[x] = a[x];
  ans = max(ans, dp[x]);
  long long max1 = 0, max2 = 0;
  for (int i = h[x]; i != -1; i = ne[i]) {
    int j = e[i];
    if (j == pre) continue;
    dfs(j, x);
    long long tem = dp[j] - w[i];
    if (tem > max1) {
      max2 = max1;
      max1 = tem;
    } else if (tem == max1)
      max2 = max1;
    else if (tem > max2) {
      max2 = tem;
    }
  }
  dp[x] = a[x] + max1;
  ans = max(ans, max(dp[x], max1 + max2 + a[x]));
}
int main() {
  int n, root;
  cin >> n;
  init();
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n - 1; i++) {
    int u, v, cos;
    scanf("%d%d%d", &u, &v, &cos);
    add(u, v, cos);
    add(v, u, cos);
  }
  dfs(1, 0);
  cout << ans << endl;
  return 0;
}
