#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;
int n, w[N + 10];
long long dp[N + 10], ans;
int tot, head[N + 10], ver[(N + 10) << 1], nxt[(N + 10) << 1],
    edge[(N + 10) << 1];
void addedge(int x, int y, int z) {
  ver[++tot] = y;
  edge[tot] = z;
  nxt[tot] = head[x];
  head[x] = tot;
}
void dfs(int x, int fa) {
  long long Max = 0;
  int from = -1;
  for (int i = head[x]; i != -1; i = nxt[i]) {
    int y = ver[i];
    if (y == fa) continue;
    dfs(y, x);
    if (Max < dp[y] - edge[i]) Max = dp[y] - edge[i], from = y;
  }
  for (int i = head[x]; i != -1; i = nxt[i]) {
    int y = ver[i];
    if (y == fa || y == from) continue;
    ans = max(ans, Max + dp[y] - edge[i] + w[x]);
  }
  dp[x] = max(0LL, Max + w[x]);
  ans = max(ans, dp[x]);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i < n; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    addedge(x, y, z);
    addedge(y, x, z);
  }
  dfs(1, 0);
  cout << ans;
  return 0;
}
