#include <bits/stdc++.h>
using namespace std;
long long int large = (long long int)1e13 + 7;
long long int mod = (long long int)1e9 + 7;
long long int const N = 300009;
long long int mod_exp(long long int x, long long int n) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % mod;
    x = (x * x) % mod;
    n = n / 2;
  }
  return result % mod;
}
long long int mod_inverse(long long int a) { return mod_exp(a, mod - 2); }
vector<pair<long long int, long long int>> adj[N];
long long int w[N];
long long int par[N] = {0};
long long int arr1[N] = {0};
long long int arr2[N] = {0};
long long int visited[N] = {0};
void dfs(long long int node) {
  visited[node] = 1;
  if (adj[node].size() == 1 && node != 1) {
    arr1[node] = w[node];
    arr2[node] = w[node];
    return;
  }
  for (auto child : adj[node]) {
    if (visited[child.first] == 0) {
      par[child.first] = node;
      dfs(child.first);
    }
  }
  long long int max1 = 0;
  long long int max2 = 0;
  for (auto child : adj[node]) {
    if (par[child.first] == node) {
      if (arr1[child.first] - child.second >= max1) {
        max2 = max1;
        max1 = arr1[child.first] - child.second;
      } else if (arr1[child.first] - child.second >= max2)
        max2 = arr1[child.first] - child.second;
    }
  }
  arr1[node] = max(w[node], w[node] + max1);
  arr2[node] = arr1[node];
  arr2[node] = max(arr2[node], w[node] + max1 + max2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T, i, j, ij;
  T = 1;
  while (T--) {
    long long int n;
    cin >> n;
    for (i = 1; i < n + 1; i++) cin >> w[i];
    long long int m = n - 1;
    while (m--) {
      long long int a, b, c;
      cin >> a >> b >> c;
      adj[a].push_back({b, c});
      adj[b].push_back({a, c});
    }
    dfs(1);
    cout << *max_element(arr2, arr2 + N);
  }
  return 0;
}
