#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 300010;
const int Mod = 1e9 + 7;
const long long INF = (long long)1e17;
vector<pair<int, int> > e[N];
int n, g[N], vis[N];
long long dp[N], ans;
void dfs(int u) {
  vis[u] = true;
  dp[u] = g[u];
  for (pair<int, int> &v : e[u]) {
    if (!vis[v.first]) {
      dfs(v.first);
      long long c = dp[v.first] - v.second;
      ans = max(ans, dp[u] + c);
      dp[u] = max(dp[u], g[u] + c);
    }
  }
  ans = max(ans, dp[u]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  for (int(i) = 0; (i) < (int)(n); ++(i)) {
    cin >> g[i];
  }
  for (int(i) = 0; (i) < (int)(n - 1); ++(i)) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    e[u].push_back({v, w});
    e[v].push_back({u, w});
  }
  dfs(0);
  cout << ans << endl;
}
