#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 15;
long long n, w[N], f[N], res;
bool vst[N];
vector<pair<long long, long long> > g[N];
void dfs(int p) {
  if (vst[p]) return;
  vst[p] = 1;
  vector<long long> h;
  for (auto it : g[p]) {
    dfs(it.second);
    h.push_back(f[it.second] - it.first);
  }
  h.push_back(0);
  h.push_back(0);
  sort(h.begin(), h.end(), greater<long long>());
  res = max(res, h[0] + h[1] + w[p]);
  f[p] = h[0] + w[p];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    long long k;
    cin >> u >> v >> k;
    u--, v--;
    g[u].push_back({k, v});
    g[v].push_back({k, u});
  }
  dfs(0);
  cout << res << endl;
}
