#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
long long dfs(long long v, long long p, vector<pair<long long, long long> > *g,
              vector<long long> &arr) {
  long long fmx = 0, smx = 0, a;
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i].first != p) {
      a = dfs(g[v][i].first, v, g, arr) - g[v][i].second;
      if (a > fmx) {
        smx = fmx;
        fmx = a;
      } else if (a > smx)
        smx = a;
    }
  }
  if (ans < fmx + smx + arr[v - 1]) ans = fmx + smx + arr[v - 1];
  return arr[v - 1] + fmx;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    int n, a, b, w;
    cin >> n;
    vector<long long> arr(n);
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] > ans) ans = arr[i];
    }
    vector<pair<long long, long long> > g[n + 1];
    for (long long i = 0; i < n - 1; i++) {
      cin >> a >> b >> w;
      g[a].push_back(make_pair(b, w));
      g[b].push_back(make_pair(a, w));
    }
    bool mark[n];
    memset(mark, 0, sizeof(mark));
    dfs(1, 0, g, arr);
    cout << ans;
  }
}
