#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long> > graph[300007];
long long a[300007], f[300007], f1[300007];
int n;
long long res = 0;
bool visit[300007];
void dfs(int u) {
  visit[u] = true;
  f[u] = 0;
  f1[u] = 0;
  for (int i = 0; i < graph[u].size(); ++i)
    if (!visit[graph[u][i].first]) {
      int v = graph[u][i].first;
      long long c = graph[u][i].second;
      dfs(v);
      if (f[v] - c + a[v] >= f[u]) {
        f1[u] = f[u];
        f[u] = max(f[u], f[v] - c + a[v]);
      } else {
        f1[u] = max(f1[u], f[v] - c + a[v]);
      }
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lli", &a[i]);
  for (int i = 1; i < n; ++i) {
    int u, v;
    long long c;
    scanf("%d%d%lli", &u, &v, &c);
    graph[u].push_back(make_pair(v, c));
    graph[v].push_back(make_pair(u, c));
  }
  dfs(1);
  for (int i = 1; i <= n; ++i) {
    res = max(res, f[i] + f1[i] + a[i]);
  }
  printf("%lli", res);
}
