#include <bits/stdc++.h>
using namespace std;
vector<int> adj[300005], cst[300005];
long long mx[300005], res, gas[300005];
long long dfs(int x, int par) {
  vector<long long> vec;
  vec.push_back(0);
  vec.push_back(0);
  for (int i = 0; i < adj[x].size(); i++) {
    int y = adj[x][i];
    if (y == par) continue;
    vec.push_back(dfs(y, x) - cst[x][i]);
  }
  sort(vec.begin(), vec.end(), greater<long long>());
  mx[x] = (vec[0] + gas[x]);
  res = max(res, vec[0] + vec[1] + gas[x]);
  return mx[x];
}
int main() {
  int n, x, y, z;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &gas[i]);
  for (int i = 1; i < n; i++) {
    scanf("%d %d %d", &x, &y, &z);
    adj[x].push_back(y);
    adj[y].push_back(x);
    cst[x].push_back(z);
    cst[y].push_back(z);
  }
  dfs(1, 1);
  printf("%lld\n", res);
  return 0;
}
