#include <bits/stdc++.h>
struct Edge {
  int dest;
  long long cost;
};
std::vector<Edge> G[1 + 300005];
long long w[1 + 300005];
long long d[1 + 300005];
long long max = 0;
void dfs(int node, int papa, long long cost) {
  std::pair<long long, long long> c;
  for (auto y : G[node])
    if (y.dest != papa) {
      dfs(y.dest, node, y.cost);
      if (d[y.dest] > c.second) c.second = d[y.dest];
      if (c.second > c.first) std::swap(c.first, c.second);
    }
  d[node] = w[node] + std::max(c.first, 0LL) - cost;
  long long tmp = w[node] + std::max(c.first, 0LL) + std::max(c.second, 0LL);
  max = std::max(max, tmp);
}
int main() {
  FILE *fi, *fo;
  fi = stdin;
  fo = stdout;
  int n;
  fscanf(fi, "%d", &n);
  for (int i = 1; i <= n; i++) fscanf(fi, "%lld", &w[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    long long c;
    fscanf(fi, "%d%d%lld", &u, &v, &c);
    G[u].push_back({v, c});
    G[v].push_back({u, c});
  }
  dfs(1, 0, 0);
  fprintf(fo, "%lld", max);
  return 0;
}
