#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int v, nxt;
  long long c;
} edge[2 * 300003];
int n, cnt;
long long ans;
long long w[300003];
int head[300003];
int fa[300003], son[300003];
long long Max1[300003], Max2[300003];
void AddEdge(int u, int v, long long c) {
  edge[cnt].v = v;
  edge[cnt].c = c;
  edge[cnt].nxt = head[u];
  head[u] = cnt++;
}
void AddMax(int u, long long tmp, int v) {
  if (tmp >= Max1[u]) {
    Max2[u] = Max1[u];
    Max1[u] = tmp;
    son[u] = v;
  } else if (tmp > Max2[u])
    Max2[u] = tmp;
}
void Dfs1(int u, int Fa) {
  Max1[u] = Max2[u] = w[u];
  for (int i = head[u]; i != -1; i = edge[i].nxt) {
    int v = edge[i].v;
    if (v == Fa) {
      fa[u] = i;
      continue;
    }
    Dfs1(v, u);
    long long tmp = w[u] + Max1[v] - edge[i].c;
    AddMax(u, tmp, v);
  }
}
void Dfs2(int u) {
  int Fa = edge[fa[u]].v;
  long long tmp;
  if (son[Fa] == u)
    tmp = Max2[Fa] - edge[fa[u]].c + w[u];
  else
    tmp = Max1[Fa] - edge[fa[u]].c + w[u];
  AddMax(u, tmp, Fa);
  ans = max(ans, Max1[u] + Max2[u] - w[u]);
  for (int i = head[u]; i != -1; i = edge[i].nxt) {
    if (i == fa[u]) continue;
    int v = edge[i].v;
    Dfs2(v);
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &w[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    long long c;
    scanf("%d %d %lld", &u, &v, &c);
    AddEdge(u, v, c);
    AddEdge(v, u, c);
  }
  Dfs1(1, 0);
  ans = Max1[1] + Max2[1] - w[1];
  for (int i = head[1]; i != -1; i = edge[i].nxt) Dfs2(edge[i].v);
  printf("%lld\n", ans);
  return 0;
}
