#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, a[N];
long long dp[N], ans;
vector<pair<int, int> > g[N];
void dfs(int v, int pr = -1) {
  long long mx1 = 0, mx2 = 0;
  for (auto it : g[v]) {
    int to = it.first, len = it.second;
    if (to != pr) {
      dfs(to, v);
      if (dp[to] - len > mx1) {
        mx2 = mx1;
        mx1 = dp[to] - len;
      } else if (dp[to] - len > mx2) {
        mx2 = dp[to] - len;
      }
    }
  }
  ans = max(ans, mx1 + mx2 + a[v]);
  dp[v] = a[v] + mx1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    g[x].push_back(make_pair(y, z));
    g[y].push_back(make_pair(x, z));
  }
  dfs(1);
  cout << ans;
}
