#include <bits/stdc++.h>
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
const long long N = 3e5;
vector<pair<long long, long long> > nei[N + 1];
bool visited[N + 1];
long long gas[N + 1];
long long res = 0ll;
long long dfs(long long v) {
  visited[v] = true;
  long long best_path = 0, second_path = 0;
  for (auto &wp : nei[v]) {
    if (!visited[wp.first]) {
      long long dwn = dfs(wp.first) - wp.second;
      if (dwn > best_path) {
        second_path = best_path;
        best_path = dwn;
      } else if (dwn > second_path) {
        second_path = dwn;
      }
    }
  }
  res = max({res, best_path + gas[v], best_path + second_path + gas[v]});
  return best_path + gas[v];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = (long long)1; i < (long long)n + 1; i++) {
    cin >> gas[i];
  }
  for (long long _ = (long long)0; _ < (long long)n - 1; _++) {
    long long u, v, c;
    cin >> u >> v >> c;
    nei[u].push_back({v, c});
    nei[v].push_back({u, c});
  }
  dfs(1);
  cout << res << "\n";
  return 0;
}
