#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > adj[300003];
long long a[300003];
long long dp[300003];
long long ans;
void dfs(long long u, long long p) {
  long long m1 = -1e17, m2 = -1e17, id = -1;
  dp[u] = a[u];
  for (long long i = 0; i < adj[u].size(); i++) {
    pair<long long, long long> v = adj[u][i];
    if (v.first != p) {
      dfs(v.first, u);
      dp[u] = max(dp[u], a[u] - v.second + dp[v.first]);
      if (dp[v.first] - v.second > m1) {
        m1 = dp[v.first] - v.second;
        id = i;
      }
    }
  }
  if (id != -1) {
    for (long long i = 0; i < adj[u].size(); i++) {
      if (i == id) continue;
      pair<long long, long long> v = adj[u][i];
      if (v.first != p) {
        m2 = max(m2, dp[v.first] - v.second);
      }
    }
  }
  ans = max(ans, dp[u]);
  ans = max(ans, a[u] + m1 + m2);
}
int main() {
  long long n, u, v, c;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (long long i = 1; i <= n - 1; i++) {
    scanf("%lld %lld", &u, &v);
    scanf("%lld", &c);
    adj[u].push_back({v, c});
    adj[v].push_back({u, c});
  }
  ans = 0;
  dfs(1, 1);
  cout << ans << endl;
  return 0;
}
