#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adj[300000];
int parent[300000], W[300000];
long long ans, D[300000];
void dfs(int c) {
  long long l1 = -0x7fffffffffffffffLL, l2 = -0x7fffffffffffffffLL;
  for (auto [n, w] : adj[c]) {
    if (parent[n] == -1) {
      parent[n] = c;
      dfs(n);
      if (l1 < D[n] - w) {
        l2 = l1;
        l1 = D[n] - w;
      } else if (l2 < D[n] - w)
        l2 = D[n] - w;
    }
  }
  ans = max(ans, D[c] = max(l1, 0LL) + W[c]);
  if (l2 != -0x7fffffffffffffffLL) ans = max(ans, l1 + l2 + W[c]);
}
int main() {
  ((void)0);
  ((void)0);
  ((void)0);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> W[i], ans = max(ans, 1LL * W[i]);
  for (int i = 1; i < N; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    adj[--a].push_back({--b, w});
    adj[b].push_back({a, w});
  }
  memset(parent, -1, sizeof(parent));
  parent[0] = 0;
  dfs(0);
  cout << ans << '\n';
  return 0;
}
