#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3 * (int)1e5 + 13;
int n;
long long w[MAXN];
vector<pair<size_t, long long>> gr[MAXN];
long long dp[MAXN];
int used[MAXN];
long long ans = 0;
long long count_dp(size_t v) {
  if (dp[v] != -1) return dp[v];
  used[v] = 1;
  if (gr[v].size() == 1) {
    dp[v] = w[v];
    ans = max(ans, w[v]);
    used[v] = 2;
    return dp[v];
  }
  long long mx = w[v];
  size_t v_mx;
  for (size_t i = 0; i < gr[v].size(); ++i) {
    auto to = gr[v][i].first;
    auto cost = gr[v][i].second;
    if (!used[to]) {
      count_dp(to);
    }
    if (mx < dp[to] + w[v] - cost) {
      mx = dp[to] + w[v] - cost;
      v_mx = to;
    }
  }
  long long smx = w[v];
  size_t v_smx;
  for (size_t i = 0; i < gr[v].size(); ++i) {
    auto to = gr[v][i].first;
    auto cost = gr[v][i].second;
    if (smx < dp[to] + w[v] - cost && to != v_mx) {
      v_smx = to;
      smx = dp[to] + w[v] - cost;
    }
  }
  ans = max(ans, mx + smx - w[v]);
  dp[v] = mx;
  used[v] = 2;
  return dp[v];
}
int main() {
  cin >> n;
  fill(dp, dp + n + 1, -1);
  for (size_t i = 1; i <= n; ++i) {
    cin >> w[i];
  }
  for (size_t i = 1; i < n; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    gr[u].emplace_back(v, c);
    gr[v].emplace_back(u, c);
  }
  for (size_t i = 1; i <= n; ++i) {
    ans = max(ans, w[i]);
    if (gr[i].size() > 1) {
      count_dp(i);
      break;
    }
  }
  cout << ans;
  return 0;
}
