#include <bits/stdc++.h>
using namespace std;
long long N, A[300010], dp[300010], ans = 0;
vector<pair<long long, long long> > G[300010];
void solve(int u, int p) {
  dp[u] = A[u];
  ans = max(ans, dp[u]);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first, l = G[u][i].second;
    if (v == p) continue;
    solve(v, u);
    ans = max(ans, dp[u] + dp[v] - l);
    dp[u] = max(dp[u], dp[v] - l + A[u]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a].push_back(make_pair(b, c));
    G[b].push_back(make_pair(a, c));
  }
  solve(1, -1);
  cout << ans << endl;
  return 0;
}
