#include <bits/stdc++.h>
using namespace std;
struct hehe {
  long long fmx, smx;
  hehe() {}
} node[300005];
vector<int> g[300005];
vector<long long> cost[300005];
long long fuel[300005], ans;
void dfs(int u, int p, long long len) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    long long w = cost[u][i];
    if (v != p) dfs(v, u, w);
  }
  long long tmp = max(0ll, node[u].fmx + fuel[u] - len);
  if (tmp >= node[p].fmx) {
    node[p].smx = node[p].fmx;
    node[p].fmx = tmp;
  } else if (tmp > node[p].smx)
    node[p].smx = tmp;
  ans = max(ans, fuel[u]);
  ans = max(ans, fuel[u] + node[u].fmx + node[u].smx);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, u, v, w;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> fuel[i];
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> w;
    g[u].push_back(v);
    cost[u].push_back(w);
    g[v].push_back(u);
    cost[v].push_back(w);
  }
  dfs(1, 0, 0);
  cout << ans << endl;
  return 0;
}
