#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535;
void FAST() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long int gas[300001];
long long int dp[300001][2];
long long int path[300001];
vector<pair<long long int, long long int>> adj[300001];
void Traveller(long long int ind, long long int par) {
  if (adj[ind].size() == 1 && ind != 1) {
    dp[ind][0] = gas[ind];
    dp[ind][1] = gas[ind];
  }
  vector<long long int> a;
  dp[ind][0] = gas[ind];
  for (auto c : adj[ind]) {
    if (c.first != par) {
      Traveller(c.first, ind);
      long long int qq = dp[c.first][0] - c.second + gas[ind];
      dp[ind][0] = max(dp[ind][0], qq);
      a.push_back(dp[c.first][0] - c.second);
    }
  }
  sort(a.begin(), a.end(), greater<long long int>());
  dp[ind][1] = gas[ind];
  if (a.size() > 0) {
    dp[ind][1] += a[0];
  }
  if (a.size() > 1) {
    dp[ind][1] += a[1];
  }
}
int main() {
  FAST();
  long long int n;
  cin >> n;
  for (long long int i = 1; i < n + 1; i++) {
    cin >> gas[i];
  }
  path[1] = 0;
  for (long long int i = 1; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    adj[a].push_back(make_pair(b, c));
    adj[b].push_back(make_pair(a, c));
  }
  Traveller(1, -1);
  long long int ans = -1e18;
  for (int i = 1; i < n + 1; i++) {
    ans = max(ans, dp[i][1]);
    ans = max(ans, dp[i][0]);
  }
  cout << ans << '\n';
  return 0;
}
