#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long a[300005];
long long dp[300005];
long long ans = 0;
vector<pair<int, long long> > v[300005];
long long dfs(int cur, int fa) {
  ans = max(ans, dp[cur]);
  for (int i = 0; i < v[cur].size(); i++) {
    int son = v[cur][i].first;
    if (son == fa) continue;
    dfs(son, cur);
    long long val = dp[son] - v[cur][i].second;
    ans = max(ans, dp[cur] + val);
    dp[cur] = max(dp[cur], a[cur] + val);
  }
  return ans;
}
int main() {
  int n;
  int u, vv, w;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    dp[i] = a[i];
  }
  for (int i = 1; i < n; i++) {
    cin >> u >> vv >> w;
    v[u].push_back({vv, w});
    v[vv].push_back({u, w});
  }
  cout << dfs(1, 0) << endl;
  return 0;
}
