#include <bits/stdc++.h>
const long long inf = std::numeric_limits<long long>::max();
const int infint = std::numeric_limits<int>::max();
const long long mod = 1e9 + 7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long ans = -1;
long long a[300100];
vector<pair<long long, long long> > g[300100];
long long dfs(int v, int p) {
  long long mx1, mx2;
  mx1 = a[v];
  mx2 = a[v];
  for (auto i : g[v]) {
    if (i.first == p) continue;
    long long now = dfs(i.first, v) - i.second + a[v];
    if (now > mx1) {
      mx2 = mx1;
      mx1 = now;
      continue;
    }
    if (now > mx2) {
      mx2 = now;
      continue;
    }
  }
  ans = max(ans, a[v]);
  if (g[v].size() - (v != 0) >= 2) {
    ans = max(ans, mx2 + mx1 - a[v]);
  }
  ans = max(ans, mx1);
  ans = max(ans, mx2);
  return mx1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    long long c;
    cin >> x >> y >> c;
    x--, y--;
    g[x].push_back({y, c});
    g[y].push_back({x, c});
  }
  dfs(0, -1);
  cout << ans;
  return 0;
}
