#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
const int inf = 1e9 + 5;
int n;
long long niz[maxn];
vector<pair<int, long long> > g[maxn];
bool cmp(long long s1, long long s2) { return s1 > s2; }
long long rez = 0;
long long dp[maxn];
void dfs(int v, int p) {
  vector<long long> vec;
  dp[v] = niz[v];
  for (auto c : g[v]) {
    int u = c.first;
    long long w = c.second;
    if (u != p) {
      dfs(u, v);
      long long kol = niz[v] - w + dp[u];
      vec.push_back(kol);
      dp[v] = max(dp[v], kol);
    }
  }
  rez = max(rez, dp[v]);
  int len = vec.size();
  if (len < 2) return;
  sort(vec.begin(), vec.end(), cmp);
  rez = max(rez, vec[0] + vec[1] - niz[v]);
}
int main() {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> niz[i];
  for (int i = 1; i <= n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  dfs(1, -1);
  cout << rez << endl;
  return 0;
}
