#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long W[N];
vector<pair<long long, long long> > G[N];
long long res[N];
long long dfs(int v, int oj);
int main() {
  int n;
  scanf("%d", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &W[i]);
  for (long long i = 1; i <= n - 1; i++) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    G[a].push_back(make_pair(b, c));
    G[b].push_back(make_pair(a, c));
  }
  dfs(1, 1);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) ans = max(ans, res[i]);
  printf("%lld\n", ans);
}
long long dfs(int v, int oj) {
  res[v] = W[v];
  long long mx = 0;
  long long mx2 = 0;
  for (auto z : G[v]) {
    if (z.first == oj) continue;
    long long R = dfs(z.first, v) - z.second;
    if (R > mx)
      mx2 = mx, mx = R;
    else if (R == mx)
      mx2 = R;
    else if (R > mx2)
      mx2 = R;
  }
  res[v] = max(res[v], mx + mx2 + W[v]);
  return mx + W[v];
}
