#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-11;
const long double pi = acos(-1.0);
int n;
long long w[1 << 19];
struct edge {
  int to;
  long long cost;
};
vector<edge> G[1 << 19];
bool used[1 << 19];
long long out = 0;
long long dfs(int id) {
  used[id] = true;
  long long res = w[id];
  vector<long long> v;
  for (int j = 0; j < G[id].size(); j++) {
    int to = G[id][j].to;
    if (used[to]) continue;
    long long sum = dfs(to) - G[id][j].cost;
    if (sum >= 0) v.push_back(sum);
  }
  sort(v.begin(), v.end(), greater<long long>());
  if (v.size() == 0) {
    out = max(out, res);
  } else if (v.size() == 1) {
    res += v[0];
    out = max(out, res);
  } else {
    res += v[0];
    out = max(out, res + v[1]);
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    long long c;
    cin >> u >> v >> c;
    u--;
    v--;
    G[u].push_back({v, c});
    G[v].push_back({u, c});
  }
  dfs(0);
  cout << out << endl;
  return 0;
}
