#include <bits/stdc++.h>
using namespace std;
vector<int> G[300002];
vector<int> L[300002];
int W[300002];
long long best = 0;
long long maxi1[300002], maxi2[300002];
vector<int> chosen[300002];
void DFS1(int u, int pd) {
  int v1 = u, v2 = -1;
  maxi1[u] = W[u];
  for (int i = 0, v, l; i < G[u].size(); i++) {
    v = G[u][i];
    l = L[u][i];
    if (v == pd) continue;
    DFS1(v, u);
    if (maxi1[v] - l > 0 && maxi2[u] < maxi1[v] - l + W[u])
      maxi2[u] = maxi1[v] - l + W[u], v2 = v;
    if (maxi1[u] < maxi2[u]) swap(maxi1[u], maxi2[u]), swap(v1, v2);
  }
  best = max(best, maxi1[u]);
  best = max(best, maxi2[u]);
  chosen[u].push_back(v1);
  chosen[u].push_back(v2);
}
void DFS2(int u, int pd, long long current) {
  best = max(best, current);
  int edge = -1;
  bool ok1, ok2;
  for (int i = 0, v, l; i < G[u].size(); i++) {
    v = G[u][i];
    l = L[u][i];
    if (v == pd) continue;
    ok1 = ok2 = false;
    if (current - l > 0) ok1 = true;
    if (chosen[u][0] != v && maxi1[u] - l > 0)
      ok2 = true;
    else if (chosen[u][0] == v && maxi2[u] - l > 0)
      swap(maxi1[u], maxi2[u]);
    if (ok1 && !ok2)
      DFS2(v, u, current - l + W[v]);
    else if (!ok1 && ok2)
      DFS2(v, u, maxi1[u] - l + W[v]);
    else if (ok1 && ok2) {
      if (current - l > maxi1[u] - l)
        DFS2(v, u, current - l + W[v]);
      else
        DFS2(v, u, maxi1[u] - l + W[v]);
    }
    if (!ok1 && !ok2) DFS2(v, u, 0);
    if (chosen[u][0] == v && maxi2[u] - l > 0) swap(maxi1[u], maxi2[u]);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int u, v, l;
  for (int i = 0; i < n; i++)
    scanf("%d", &W[i]), maxi2[i] = -1, best = max(best, 1LL * W[i]);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d%d", &u, &v, &l);
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
    L[u].push_back(l);
    L[v].push_back(l);
  }
  DFS1(0, -1);
  DFS2(0, -1, 0);
  cout << best << endl;
}
