#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
int n;
long long w[maxn], ma[maxn][2], ans;
vector<int> a[maxn];
vector<long long> c[maxn];
bool visited[maxn];
void dfs(int u) {
  visited[u] = true;
  for (int i = 0; i < (int)a[u].size(); ++i) {
    int v = a[u][i];
    if (visited[v]) continue;
    dfs(v);
    long long vC = ma[v][0] - c[u][i];
    if (vC > ma[u][0]) {
      ma[u][1] = ma[u][0];
      ma[u][0] = vC;
    } else {
      if (vC > ma[u][1]) {
        ma[u][1] = vC;
      }
    }
  }
  ans = max(ans, ma[u][0] + ma[u][1] + w[u]);
  ma[u][0] += w[u];
  ma[u][1] += w[u];
}
int main(int argc, const char* argv[]) {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> w[i];
  }
  for (int i = 1; i < n; ++i) {
    int u, v, C;
    cin >> u >> v >> C;
    a[u].push_back(v);
    c[u].push_back(C);
    a[v].push_back(u);
    c[v].push_back(C);
  }
  dfs(1);
  cout << ans;
  return 0;
}
