#include <bits/stdc++.h>
long long mod = 1000000007;
using namespace std;
int n;
long long ans = -1;
long long fuel[300005];
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
vector<pair<int, int> > G[300005];
long long dfs(int v, int par) {
  long long bonus = fuel[v];
  vector<long long> pots;
  for (int i = 0; i < G[v].size(); i++) {
    int tar = G[v][i].first;
    long long cost = G[v][i].second;
    if (tar == par) {
      continue;
    }
    long long chil = dfs(tar, v);
    pots.push_back(chil - cost);
    ans = max(chil - cost + bonus, ans);
  }
  sort(pots.begin(), pots.end());
  int sz = pots.size();
  if (sz >= 2) {
    ans = max(ans, pots[sz - 1] + pots[sz - 2] + bonus);
  }
  if (sz) return max(bonus, pots[sz - 1] + bonus);
  return bonus;
}
int main() {
  int i, j, fl, test;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &fuel[i]);
    ans = max(ans, fuel[i]);
  }
  for (i = 1; i <= n - 1; i++) {
    int x, y;
    long long w;
    scanf("%d%d%lld", &x, &y, &w);
    G[x].push_back(make_pair(y, w));
    G[y].push_back(make_pair(x, w));
  }
  dfs(1, -1);
  printf("%lld\n", ans);
  return 0;
}
