#include <bits/stdc++.h>
using namespace std;
int n;
long long res = 0;
long long w[300003];
long long dp[300003][2];
vector<pair<int, long long> > g[300003];
void go(int u, int p) {
  vector<long long> foo;
  for (auto e : g[u]) {
    int v = e.first;
    if (v == p) continue;
    go(v, u);
    foo.push_back(-e.second + w[v] + dp[v][0]);
  }
  sort(foo.begin(), foo.end());
  reverse(foo.begin(), foo.end());
  dp[u][0] = dp[u][1] = 0;
  if (((int)(foo.size())) > 0) {
    dp[u][0] = max(dp[u][0], foo[0]);
  }
  if (((int)(foo.size())) > 1) {
    dp[u][1] = max(dp[u][1], foo[1]);
  }
  res = max(res, w[u] + dp[u][0]);
  res = max(res, w[u] + dp[u][0] + dp[u][1]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
    res = max(res, w[i]);
  }
  long long z;
  int x, y;
  for (int i = 1; i < n; i++) {
    cin >> x >> y >> z;
    g[x].push_back({y, z});
    g[y].push_back({x, z});
  }
  go(1, 0);
  cout << res << '\n';
  return 0;
}
