#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x > y ? y : x; }
bool cmp(long long x, long long y) { return x > y; }
long long gcd(long long x, long long y) { return (y == 0) ? x : gcd(y, x % y); }
template <typename T>
void read(T& x) {
  int ch = getchar();
  x = 0;
  bool f = false;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') {
    f = true;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  if (f) x = -x;
}
long long a[300050] = {0};
long long label[300050] = {0};
long long ans = 0;
struct GGGabc {
  long long po;
  long long va;
};
vector<GGGabc> v[300050];
long long solve(long long r) {
  label[r] = 1;
  long long max1 = 0, max2 = 0;
  for (auto e : v[r]) {
    if (label[e.po] == 0) {
      label[e.po] = 1;
      long long x = solve(e.po) - e.va;
      if (x > max1) {
        max2 = max1;
        max1 = x;
        continue;
      }
      if (x > max2) {
        max2 = x;
        continue;
      }
    }
  }
  ans = max(ans, a[r] + max1 + max2);
  return a[r] + max1;
}
int main() {
  long long n = 0, m = 0, t = 0;
  long long i = 0, j = 0, k = 0;
  long long x = 0, y = 0, z = 0;
  GGGabc q, p;
  read(n);
  for (i = 1; i <= n; i++) {
    read(a[i]);
    ans = max(ans, a[i]);
  }
  for (i = 1; i <= n - 1; i++) {
    read(x);
    read(y);
    read(z);
    q.po = y;
    q.va = z;
    p.po = x;
    p.va = z;
    v[x].push_back(q);
    v[y].push_back(p);
  }
  solve(1);
  cout << ans << endl;
  return 0;
}
