#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 2e9;
const long long N = 3e5 + 35;
vector<pair<long long, long long>> adj[N];
long long a[N], mx[N], n, ans;
void dfs(long long x, long long p) {
  mx[x] = a[x];
  for (auto &i : adj[x]) {
    if (i.first == p) continue;
    dfs(i.first, x);
    ans = max(ans, mx[x] + mx[i.first] - i.second);
    mx[x] = max(mx[x], mx[i.first] - i.second + a[x]);
  }
  ans = max(ans, mx[x]);
}
void kudne() {
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> a[i];
  for (long long i = 1; i < n; ++i) {
    long long x, y, z;
    cin >> x >> y >> z;
    adj[x].push_back({y, z});
    adj[y].push_back({x, z});
  }
  dfs(1, -1);
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long tc = 1;
  for (long long i = 1; i <= tc; ++i) {
    kudne();
    if (i < tc) cout << "\n";
  }
  return 0;
}
