#include <bits/stdc++.h>
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
using namespace std;
vector<pair<long long int, long long int> > v[300001];
bool vis[300001] = {0};
long long int arr[300001];
long long int opt[300001], ans[300001];
void dfs(long long int cur) {
  if (!vis[cur]) {
    vis[cur] = 1;
    opt[cur] = ans[cur] = arr[cur];
    vector<long long int> carr;
    for (long long int i = 0; i < v[cur].size(); i++) {
      if (!vis[v[cur][i].first]) {
        dfs(v[cur][i].first);
        long long int p = arr[cur] - v[cur][i].second + opt[v[cur][i].first];
        carr.push_back(p);
        opt[cur] = max(opt[cur], p);
      }
    }
    if (carr.size()) {
      ans[cur] = opt[cur];
      if (carr.size() >= 2) {
        sort(carr.begin(), carr.end());
        ans[cur] = max(
            ans[cur], carr[carr.size() - 1] + carr[carr.size() - 2] - arr[cur]);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  for (long long int i = 1; i < n + 1; i++) cin >> arr[i];
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y, wt;
    cin >> x >> y >> wt;
    v[x].push_back({y, wt});
    v[y].push_back({x, wt});
  }
  dfs(1);
  long long int yoo = INT_MIN;
  for (long long int i = 1; i < n + 1; i++) yoo = max(yoo, ans[i]);
  cout << yoo;
  return 0;
}
