#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 229;
const long long M = 1e9 + 7;
const long long M2 = 1e9 + 9;
const long long mod = 998244353;
const int rx[8] = {1, 1, -1, -1, -2, -2, 2, 2};
const int ry[8] = {-2, 2, -2, 2, 1, -1, 1, -1};
const long double eps = 1e-7;
const double pi = acos(-1.0);
vector<pair<int, long long> > g[N];
long long c[N], ot = 0, calc[N];
void dfs(int v, int p = 0) {
  for (auto to : g[v]) {
    if (to.first == p) {
      continue;
    }
    dfs(to.first, v);
  }
  long long best1 = 0, best2 = 0;
  for (auto to : g[v]) {
    if (to.first == p) {
      continue;
    }
    if (calc[to.first] - to.second > best1) {
      swap(best1, best2);
      best1 = calc[to.first] - to.second;
    } else if (calc[to.first] - to.second > best2) {
      best2 = calc[to.first] - to.second;
    }
  }
  calc[v] = best1 + c[v];
  ot = max(ot, best1 + best2 + c[v]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  int n, x, y;
  long long w;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  for (int i = 1; i < n; ++i) {
    cin >> x >> y >> w;
    --x;
    --y;
    g[x].push_back({y, w});
    g[y].push_back({x, w});
  }
  dfs(0);
  cout << ot;
  return 0;
}
