#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000 + 100;
long long a[maxn];
long long dp[maxn];
long long dp2[maxn];
vector<int> G[maxn], dist[maxn];
long long int ans = 0;
void dfs(int u, int fa) {
  long long int max1 = 0, max2 = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    dfs(v, u);
    if (dp[v] - dist[u][i] > max1) {
      max2 = max1;
      max1 = dp[v] - dist[u][i];
    } else if (dp[v] - dist[u][i] == max1) {
      max2 = max1;
    } else {
      if (dp[v] - dist[u][i] > max2) {
        max2 = dp[v] - dist[u][i];
      }
    }
  }
  dp[u] = a[u] + max1;
  dp2[u] = max1 + max2 + a[u];
  if (dp[u] > ans) {
    ans = dp[u];
  }
  if (dp2[u] > ans) {
    ans = dp2[u];
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  int x, y, w;
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &x, &y, &w);
    G[x].push_back(y);
    G[y].push_back(x);
    dist[x].push_back(w);
    dist[y].push_back(w);
  }
  dfs(1, -1);
  printf("%lld", ans);
}
