#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, u, v, c, w[N];
vector<pair<int, int> > adj[N];
long long f[N], g[N];
void DFS(int u, int P) {
  long long m1 = 0, m2 = 0;
  for (pair<int, int> p : adj[u]) {
    int v = p.first, uv = p.second;
    if (v == P) continue;
    DFS(v, u);
    if (m1 <= f[v] - uv)
      m2 = m1, m1 = f[v] - uv;
    else if (m2 < f[v] - uv)
      m2 = f[v] - uv;
  }
  f[u] = m1 + w[u];
  g[u] = m1 + w[u] + m2;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> w[i], f[i] = w[i];
  for (int i = 2; i <= n; i++)
    cin >> u >> v >> c, adj[u].push_back({v, c}), adj[v].push_back({u, c});
  DFS(1, 1);
  cout << max(*max_element(f + 1, f + n + 1), *max_element(g + 1, g + n + 1));
  return 0;
}
