#include <bits/stdc++.h>
using namespace std;
long long n, a[300020], dis[300030], vis[300030], ans;
vector<pair<long long, long long>> adj[300030];
vector<long long> v[300030];
void dfs(int s) {
  vis[s] = 1;
  for (auto p : adj[s]) {
    if (vis[p.first] == 0) {
      dfs(p.first);
      v[s].push_back(dis[p.first] - p.second);
    }
  }
  sort(v[s].rbegin(), v[s].rend());
  if ((int)v[s].size())
    dis[s] += max(a[s], a[s] + v[s][0]);
  else
    dis[s] = a[s];
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    ans = max(a[i], ans);
  }
  long long x, y, c;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%lld%lld%lld", &x, &y, &c);
    adj[x].push_back({y, c});
    adj[y].push_back({x, c});
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if ((int)v[i].size() > 1) ans = max(ans, a[i] + v[i][0] + v[i][1]);
    if ((int)v[i].size()) ans = max(ans, a[i] + v[i][0]);
  }
  cout << ans;
  return 0;
}
