#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long int, long long int> > > graph(300007);
bool visited[300007];
long long int val[300007];
long long int ans = 0;
long long int dfs(int v) {
  visited[v] = true;
  long long int maxm = 0, second_maxm = 0;
  for (int i = 0; i < graph[v].size(); i++) {
    int child = graph[v][i].first;
    long long int cap = graph[v][i].second;
    if (visited[child]) continue;
    long long int x = dfs(child);
    if (x - cap < 0) continue;
    long long int y = x - cap;
    if (y > maxm) {
      second_maxm = maxm;
      maxm = y;
    } else if (y > second_maxm)
      second_maxm = y;
  }
  ans = max(ans, maxm + second_maxm + val[v]);
  return maxm + val[v];
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) visited[i] = false;
  for (int i = 1; i <= n; i++) cin >> val[i];
  for (int i = 1; i < n; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    graph[a].push_back(make_pair(b, c));
    graph[b].push_back(make_pair(a, c));
  }
  dfs(1);
  cout << ans << '\n';
}
