#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long gas;
  vector<int> edge_to;
  vector<long long> edge_w;
  long long ans;
  long long half;
};
Node nodes[300001];
void dfs(int u, int par) {
  Node &n = nodes[u];
  n.ans = n.half = n.gas;
  long long mh1 = 0, mh2 = 0;
  for (int i = 0; i < n.edge_to.size(); i++) {
    int v = n.edge_to[i];
    if (v == par) continue;
    dfs(v, u);
    long long rm = nodes[v].half - n.edge_w[i];
    if (rm > mh1) swap(rm, mh1);
    if (rm > mh2) swap(rm, mh2);
    n.ans = max(n.ans, nodes[v].ans);
  }
  n.half = max(n.half, mh1 + n.gas);
  n.ans = max(n.ans, n.gas + mh1 + mh2);
}
int main() {
  int n, i, u, v, w;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> nodes[i].gas;
  }
  for (i = 1; i < n; i++) {
    cin >> u >> v >> w;
    nodes[u].edge_to.push_back(v);
    nodes[v].edge_to.push_back(u);
    nodes[u].edge_w.push_back(w);
    nodes[v].edge_w.push_back(w);
  }
  dfs(1, 0);
  cout << nodes[1].ans << endl;
  return 0;
}
