#include <bits/stdc++.h>
using namespace std;
int n, w[300010];
vector<pair<int, int> > G[300010];
long long res, f[300010];
void DFS(int u, int fa) {
  f[u] = w[u];
  long long Max[2] = {0, 0};
  for (auto it : G[u]) {
    int v = it.first;
    if (v == fa) continue;
    DFS(v, u);
    long long cost = it.second;
    f[u] = max(f[u], f[v] - cost + w[u]);
    long long tmp = f[v] - cost;
    if (tmp > Max[0]) {
      Max[1] = Max[0];
      Max[0] = tmp;
    } else if (tmp > Max[1])
      Max[1] = tmp;
  }
  res = max(res, max(f[u], Max[0] + Max[1] + w[u]));
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i) scanf("%d", w + i);
    for (int i = 1; i <= n; ++i) G[i].clear();
    for (int i = 1, u, v, w; i < n; ++i) {
      scanf("%d%d%d", &u, &v, &w);
      G[u].emplace_back(v, w);
      G[v].emplace_back(u, w);
    }
    res = 0;
    DFS(1, 1);
    printf("%lld\n", res);
  }
  return 0;
}
