#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > adj[300005];
long long int maxdown[300005];
long long int fuel[300005];
long long int ans = -1;
void dfs(int u, int p) {
  for (pair<int, int> i : adj[u]) {
    if (i.second != p) dfs(i.second, u);
  }
  maxdown[u] = fuel[u];
  for (pair<int, int> i : adj[u]) {
    if (i.second != p)
      maxdown[u] = max(maxdown[u], fuel[u] - i.first + maxdown[i.second]);
  }
}
void dfs2(int u, int p) {
  vector<long long int> toSort;
  for (pair<int, int> i : adj[u]) {
    if (i.second != p) {
      dfs2(i.second, u);
      toSort.push_back(maxdown[i.second] - i.first);
    }
  }
  if (toSort.size() == 0) {
    ans = max(ans, 1LL * fuel[u]);
    return;
  }
  sort(toSort.begin(), toSort.end());
  long long int this_ans = 1LL * fuel[u];
  if (toSort[toSort.size() - 1] > 0) this_ans += toSort[toSort.size() - 1];
  if (toSort.size() > 1 && toSort[toSort.size() - 2] > 0)
    this_ans += toSort[toSort.size() - 2];
  ans = max(ans, this_ans);
}
int main() {
  int n, u, v, c;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> fuel[i + 1];
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v >> c;
    adj[u].push_back({c, v});
    adj[v].push_back({c, u});
  }
  dfs(1, 0);
  dfs2(1, 0);
  cout << ans << endl;
}
