#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
vector<pair<long long int, long long int> > tree[300000];
vector<long long int> w(300000), down(300000, 0);
void dfs(long long int u, long long int par, long long int& ans) {
  long long int curr = w[u], temp;
  priority_queue<long long int> pq;
  for (int v = (0); v < (tree[u].size()); v++) {
    if (tree[u][v].first == par) continue;
    dfs(tree[u][v].first, u, ans);
    pq.push(-1 * (-1 * tree[u][v].second + down[tree[u][v].first]));
    if (pq.size() == 3) pq.pop();
    curr = max(curr, w[u] - tree[u][v].second + down[tree[u][v].first]);
  }
  if (pq.size() == 2) {
    temp = -1 * pq.top();
    pq.pop();
    temp -= pq.top();
    temp += w[u];
    pq.pop();
    ans = max(ans, temp);
  }
  down[u] = curr;
  ans = max(ans, max(w[u], down[u]));
}
int main() {
  long long int n, u, v, c;
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> w[i];
  for (int i = (0); i < (n - 1); i++) {
    cin >> u >> v >> c;
    u--, v--;
    tree[u].push_back({v, c}), tree[v].push_back({u, c});
  }
  long long int ans = LLONG_MIN;
  dfs(0, -1, ans);
  cout << ans;
  return 0;
}
