#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 40;
long long int w[N + 3];
vector<vector<pair<int, long long int> > > adj(N);
bool vis[N];
long long int mx[N];
long long int ans = -1e18;
void dfs(int v) {
  vis[v] = 1;
  multiset<long long int> second;
  for (auto u : adj[v]) {
    if (!vis[u.first]) {
      dfs(u.first);
      second.insert(-(mx[u.first] + u.second));
    }
  }
  if (second.size()) {
    if (second.size() == 1) {
      long long int mxs = *second.begin();
      mxs = -mxs;
      mx[v] = max(mx[v], mx[v] + mxs);
    } else {
      long long int mxs1 = *second.begin();
      second.erase(second.find(mxs1));
      mxs1 = -mxs1;
      long long int mxs2 = *second.begin();
      mxs2 = -mxs2;
      ans = max(ans, mxs1 + mxs2 + mx[v]);
      mx[v] = max(mx[v], mx[v] + mxs1);
    }
  }
}
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
    mx[i] = w[i];
  }
  for (int i = 1; i <= n - 1; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    adj[u].push_back(make_pair(v, -c));
    adj[v].push_back(make_pair(u, -c));
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    ans = max(ans, mx[i]);
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
}
