#include <bits/stdc++.h>
using namespace std;
int n;
int a[300005];
struct node {
  int v, w;
  node(int v, int w) : v(v), w(w){};
  node(){};
};
vector<node> e[300005];
long long int val[300005], ans;
void dfs(int x, int fa) {
  val[x] = a[x];
  ans = max(ans, val[x]);
  for (int i = 0; i < e[x].size(); i++) {
    node now = e[x][i];
    int v = now.v;
    int w = now.w;
    if (v == fa) continue;
    dfs(v, x);
    ans = max(ans, val[x] + val[v] - w);
    val[x] = max(val[x], a[x] + val[v] - w);
  }
  return;
}
int main() {
  memset(val, 0, sizeof(val));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1, x, y, z; i < n; i++) {
    scanf("%d%d%d", &x, &y, &z);
    e[x].push_back(node(y, z));
    e[y].push_back(node(x, z));
  }
  dfs(1, -1);
  printf("%lld\n", ans);
  return 0;
}
