#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int M = 2050;
const int MOD = 998244353;
const int rx[4] = {1, -1, 0, 0};
const int ry[4] = {0, 0, 1, -1};
vector<pair<int, long long> > g[N];
long long ot[N];
long long used[N];
long long ans = 0;
long long a[N];
void dfs(int v, int p) {
  vector<long long> kek;
  used[v] = 1;
  for (auto it : g[v]) {
    int to = it.first, w = it.second;
    if (used[to]) continue;
    dfs(to, v);
    kek.push_back(ot[to] - w);
  }
  kek.push_back(0);
  kek.push_back(0);
  sort(kek.rbegin(), kek.rend());
  ans = max(kek[0] + kek[1] + a[v], ans);
  ot[v] = kek[0] + a[v];
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    g[x].push_back({y, z});
    g[y].push_back({x, z});
  }
  dfs(0, 0);
  for (int i = 0; i < n; i++) ans = max(ans, ot[i]);
  cout << ans << '\n';
}
