#include <bits/stdc++.h>
using namespace std;
class TaskA {
  int64_t n;
  vector<int64_t> w;
  vector<vector<pair<int64_t, int64_t>>> g;
  vector<int64_t> dp, res;
  void dfs(int64_t u, int64_t p = -1) {
    priority_queue<int64_t> cur;
    for (auto v : g[u]) {
      if (v.first != p) {
        dfs(v.first, u);
        dp[u] = max(dp[u], dp[v.first] - v.second + w[u]);
        cur.emplace(dp[v.first] - v.second);
      }
    }
    if (!cur.empty()) {
      int64_t s = cur.top();
      cur.pop();
      res[u] = max(res[u], s + w[u]);
      if (!cur.empty()) {
        int64_t t = cur.top();
        cur.pop();
        res[u] = max(res[u], s + t + w[u]);
      }
    }
  }

 public:
  TaskA(int64_t n) {
    this->n = n;
    w.resize(n);
    g.resize(n);
    dp.resize(n);
    res.resize(n);
    for (int64_t i = 0; i < n; i++) {
      cin >> w[i];
      dp[i] = w[i];
      res[i] = w[i];
    }
    for (int64_t u, v, w, i = 1; i < n; i++) {
      cin >> u >> v >> w;
      g[u - 1].emplace_back(v - 1, w);
      g[v - 1].emplace_back(u - 1, w);
    }
  }
  int64_t solve() {
    dfs(0);
    return *max_element(res.begin(), res.end());
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int64_t n;
  cin >> n;
  TaskA A(n);
  cout << A.solve() << '\n';
}
