#include <bits/stdc++.h>
const long long int mod = 1000000007;
using namespace std;
const int N = 1000000;
long long int cost[N], n;
bool vis[N];
vector<pair<long long int, long long int>> g[N];
long long int dp[N];
long long int ans;
void dfs(int node, int p, int dist = 0) {
  vis[node] = true;
  dp[node] = cost[node];
  vector<long long int> nik;
  nik.clear();
  nik.push_back(0);
  nik.push_back(0);
  for (auto pr : g[node]) {
    long long int v = pr.first;
    long long int c = pr.second;
    if (vis[v]) continue;
    dfs(v, node);
    dp[node] = max(dp[node], cost[node] + dp[v] - c);
    nik.push_back(dp[v] - c);
  }
  sort(nik.rbegin(), nik.rend());
  ans = max(ans, nik[0] + nik[1] + cost[node]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> cost[i];
  for (int i = 1; i < n; i++) {
    long long int u, v, c;
    cin >> u >> v >> c;
    g[u].push_back({v, c});
    g[v].push_back({u, c});
  }
  dfs(1, 0);
  cout << ans << endl;
  return 0;
}
