#include <bits/stdc++.h>
using namespace std;
int n, gas[300005];
vector<pair<int, int> > a[300005];
bool ca[300005];
long long res;
long long dfs(int u) {
  ca[u] = true;
  long long ret = gas[u];
  res = max(res, ret);
  for (auto i : a[u]) {
    int v = i.first;
    int w = i.second;
    if (ca[v]) continue;
    long long tg = dfs(v) - w;
    res = max(res, ret + tg);
    ret = max(ret, gas[u] + tg);
  }
  return ret;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> gas[i];
  for (int i = 1; i < n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    a[u].push_back(pair<int, int>(v, w));
    a[v].push_back(pair<int, int>(u, w));
  }
  dfs(1);
  cout << res;
}
