#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, w[N];
vector<pair<int, int> > adj[N];
long long int dp[N], ans = 0;
int dfs(int u, int p) {
  long long int best[2] = {0, 0};
  for (auto vc : adj[u]) {
    int v, c;
    tie(v, c) = vc;
    if (v == p) continue;
    dfs(v, u);
    if (dp[v] - c > best[1]) best[1] = dp[v] - c;
    if (best[1] > best[0]) swap(best[0], best[1]);
  }
  ans = max(ans, best[0] + best[1] + w[u]);
  return dp[u] = best[0] + w[u];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); i++) scanf("%d", &w[i]);
  for (int _ = 0; _ < (int)(n - 1); _++) {
    int u, v, c;
    scanf("%d %d %d", &u, &v, &c);
    --u;
    --v;
    adj[u].emplace_back(v, c);
    adj[v].emplace_back(u, c);
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
