#include <bits/stdc++.h>
using namespace std;
const int mxn = 4e5;
long long n, ans, d[mxn], w[mxn], a, b, c;
bool m[mxn];
vector<pair<int, int>> v[mxn];
long long dfs(int s) {
  long long t = w[s];
  m[s] = 1;
  for (int i = 0; i < v[s].size(); i++) {
    if (!m[v[s][i].first]) {
      long long temp = dfs(v[s][i].first);
      ans = max(ans, t - v[s][i].second + temp);
      t = max(t, w[s] - v[s][i].second + temp);
    }
  }
  d[s] = t;
  ans = max(ans, t);
  return t;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i < n; i++) {
    cin >> a >> b >> c;
    v[a].push_back({b, c});
    v[b].push_back({a, c});
  }
  dfs(1);
  cout << ans;
  return 0;
}
