#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 5;
long long N, ans;
long long w[maxn], down[maxn], dp[maxn];
vector<pair<long long, long long> > G[maxn];
void dfs(long long u, long long k) {
  down[u] = w[u];
  long long a = 0, b = 0;
  for (auto p : G[u]) {
    long long v = p.first, c = p.second;
    if (v == k) continue;
    dfs(v, u);
    if (down[v] - c >= a) {
      b = a, a = down[v] - c;
    } else
      b = max(b, down[v] - c);
  }
  down[u] = w[u] + a;
  ans = max(ans, a + b + w[u]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (long long i = 1; i <= N; i++) cin >> w[i];
  for (long long i = 1; i <= N - 1; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    G[u].push_back(make_pair(v, c));
    G[v].push_back(make_pair(u, c));
  }
  dfs(1, 0);
  cout << ans << "\n";
  return 0;
}
