#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1;
vector<pair<int, long long>> g[N];
long long dp[N][2], c[N];
void dfs(int v, int p) {
  dp[v][0] = dp[v][1] = c[v];
  vector<long long> edge;
  for (auto u : g[v]) {
    if (u.first == p) {
      continue;
    }
    dfs(u.first, v);
    edge.push_back(dp[u.first][0] - u.second);
    dp[v][0] = max(dp[v][0], -u.second + dp[u.first][0] + c[v]);
  }
  sort(edge.begin(), edge.end());
  reverse(edge.begin(), edge.end());
  if (edge.size() > 1) {
    dp[v][1] = max(dp[v][1], edge[0] + c[v] + edge[1]);
  }
}
int main() {
  int n;
  long long ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 0, v, u, w; i < n - 1; i++) {
    cin >> v >> u >> w;
    g[v].push_back({u, w});
    g[u].push_back({v, w});
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    ans = max(ans, max(dp[i][0], dp[i][1]));
  }
  cout << ans;
}
