#include <bits/stdc++.h>
using namespace std;
long long w[300000];
bool marked[300000];
long long ans = 0;
long long dfs(int p, vector<vector<pair<int, long long>>> &graph) {
  marked[p] = true;
  long long dev = w[p];
  long long ma1 = 0, ma2 = 0;
  for (int i = 0; i < graph[p].size(); ++i) {
    long long va = 0;
    if (!marked[graph[p][i].first])
      va = dfs(graph[p][i].first, graph) - graph[p][i].second;
    if (ma1 < va) {
      ma2 = ma1;
      ma1 = va;
    } else if (ma2 < va) {
      ma2 = va;
    }
  }
  ans = max(ans, ma1 + ma2 + dev);
  return ma1 + dev;
}
int main() {
  int n;
  scanf(" %d", &n);
  for (int i = 0; i < n; ++i) cin >> w[i];
  vector<vector<pair<int, long long>>> graph(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    long long c;
    cin >> a >> b >> c;
    --a;
    --b;
    graph[a].push_back({b, c});
    graph[b].push_back({a, c});
  }
  dfs(0, graph);
  cout << ans << endl;
  return 0;
}
