#include <bits/stdc++.h>
using namespace std;
using namespace std;
int N;
long long A[300005];
long long ans = 0;
vector<pair<int, long long> > adj[300005];
long long dfs(int u, int p) {
  long long tmp = A[u];
  long long max1 = 0, max2 = 0;
  for (unsigned int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    long long c = adj[u][i].second;
    if (v == p) continue;
    long long vc = dfs(v, u) - c;
    if (vc <= max2) continue;
    if (vc <= max1) {
      max2 = vc;
      continue;
    }
    max2 = max1;
    max1 = vc;
    continue;
  }
  ans = max(ans, tmp + max1 + max2);
  return tmp + max1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 1; i < N; i++) {
    int u, v;
    long long c;
    cin >> u >> v >> c;
    adj[u].push_back({v, c});
    adj[v].push_back({u, c});
  }
  dfs(1, 0);
  cout << ans << endl;
}
