#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 1000;
long long c[maxn];
struct node {
  int to;
  long long len;
};
vector<node> G[maxn];
long long dp1[maxn];
long long dp2[maxn];
long long ans = 0;
void dfs(int v, int fa) {
  dp1[v] = c[v];
  dp2[v] = c[v];
  long long c1 = 0;
  long long c2 = 0;
  long long k = 0;
  for (int i = 0; i < G[v].size(); i++) {
    int to = G[v][i].to;
    long long len = G[v][i].len;
    if (to == fa) continue;
    dfs(to, v);
    k = max(k, dp1[to] - len);
    if (dp1[to] - len >= c1) {
      c2 = c1;
      c1 = dp1[to] - len;
    } else if (dp1[to] - len >= c2) {
      c2 = dp1[to] - len;
    }
  }
  dp1[v] += k;
  dp2[v] += (c1 + c2);
  ans = max(dp2[v], ans);
}
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> c[i];
  for (int i = 1; i < N; i++) {
    int x;
    int y;
    long long len;
    cin >> x >> y >> len;
    G[x].push_back(node{y, len});
    G[y].push_back(node{x, len});
  }
  dfs(1, 0);
  cout << ans << endl;
  return 0;
}
