#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n;
int a[N];
vector<pair<int, int> > g[N];
long long ans;
long long dp[N];
void dfs(int u, int fa) {
  dp[u] = a[u];
  long long M1 = 0, M2 = 0;
  for (auto it : g[u]) {
    int v = it.first;
    int w = it.second;
    if (v == fa) continue;
    dfs(v, u);
    long long t = dp[v] - w;
    if (t > M1)
      M2 = M1, M1 = t;
    else if (t > M2)
      M2 = t;
    if (dp[v] > w) {
      dp[u] = max(dp[u], dp[v] + a[u] - w);
    }
  }
  ans = max(ans, dp[u]);
  ans = max(ans, M1 + M2 + a[u]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  dfs(1, 0);
  cout << ans;
}
