#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
vector<pair<int, long long> > g[N];
long long dp[N];
long long w[N];
long long ans = 0;
void dfs(int u, int c) {
  dp[u] = w[u];
  ans = max(ans, dp[u]);
  for (auto v : g[u]) {
    if (v.first == c) continue;
    dfs(v.first, u);
    ans = max(ans, dp[u] + dp[v.first] - v.second);
    dp[u] = max(dp[u], w[u] + dp[v.first] - v.second);
  }
}
int main() {
  int n, u, v;
  long long c;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", w + i);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%I64d", &u, &v, &c);
    g[u].push_back({v, c});
    g[v].push_back({u, c});
  }
  dfs(1, 0);
  printf("%I64d\n", ans);
  return 0;
}
