#include <bits/stdc++.h>
using namespace std;
int n, m, s;
long long dp[320000];
long long jy[320000];
vector<pair<int, long long> > v[320000];
long long ans = 0;
long long dfs(int now, int pre) {
  ans = max(ans, dp[now]);
  for (int i = 0; i < v[now].size(); i++) {
    int son = v[now][i].first;
    if (son == pre) continue;
    dfs(son, now);
    long long tem = dp[son] - v[now][i].second;
    ans = max(ans, dp[now] + tem);
    dp[now] = max(dp[now], jy[now] + tem);
  }
  return ans;
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &jy[i]);
      dp[i] = jy[i];
    }
    for (int i = 1; i <= n - 1; i++) {
      int ta, tb, tc;
      scanf("%d%d%d", &ta, &tb, &tc);
      v[ta].push_back({tb, tc});
      v[tb].push_back({ta, tc});
    }
    printf("%lld\n", dfs(1, 0));
  }
}
