#include <bits/stdc++.h>
using namespace std;
long long n;
vector<pair<long long, long long> > v[400000];
long long w[400000];
bool visited[400000];
long long ans = -1;
long long dfs(long long s) {
  visited[s] = true;
  long long cur = w[s];
  for (long long i = 0; i < v[s].size(); i++) {
    if (visited[v[s][i].first] == 0) {
      long long kp = dfs(v[s][i].first);
      kp -= v[s][i].second;
      ans = max(ans, cur + kp);
      cur = max(cur, w[s] + kp);
    }
  }
  return cur;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> w[i];
    ans = max(ans, w[i]);
  }
  for (long long i = 0; i < n - 1; i++) {
    long long x, y, c;
    cin >> x >> y >> c;
    v[x].push_back({y, c});
    v[y].push_back({x, c});
  }
  dfs(1);
  cout << ans;
}
