#include <bits/stdc++.h>
using namespace std;
inline long long add(long long a, long long b) {
  return ((a % 1000000007LL) + (b % 1000000007LL)) % 1000000007LL;
}
inline long long mul(long long a, long long b) {
  return ((a % 1000000007LL) * (b % 1000000007LL)) % 1000000007LL;
}
inline long long sub(long long a, long long b) {
  return ((a % 1000000007LL) - (b % 1000000007LL) + 1000000007LL) %
         1000000007LL;
}
long long gas[300000LL];
long long mx[300000LL];
vector<long long> adj[300000LL];
multiset<long long, greater<long long>> findMax[300000LL];
map<pair<long long, long long>, long long> len;
long long dfs(long long i, long long p, long long &ans) {
  findMax[i].insert(gas[i]), findMax[i].insert(gas[i]);
  long long firstMax, secondMax, temp, ret;
  for (auto it : adj[i]) {
    if (it == p) {
      continue;
    }
    temp = dfs(it, i, ans) + gas[i] - len[make_pair(i, it)];
    findMax[i].insert(temp);
  }
  firstMax = *findMax[i].begin(), findMax[i].erase(findMax[i].find(firstMax));
  secondMax = *findMax[i].begin(), findMax[i].erase(findMax[i].find(secondMax));
  ans = max(ans, firstMax + secondMax - gas[i]);
  findMax[i].insert(firstMax), findMax[i].insert(secondMax);
  return mx[i] = firstMax;
}
void dfs2(long long i, long long p, long long &ans, long long pMax) {
  ans = max(ans, mx[i] + pMax - len[make_pair(i, p)]);
  for (auto it : adj[i]) {
    if (it == p) {
      continue;
    }
    findMax[i].erase(findMax[i].find(mx[it] + gas[i] - len[make_pair(i, it)]));
    dfs2(it, i, ans, *findMax[i].begin());
    findMax[i].insert((mx[it] + gas[i] - len[make_pair(i, it)]));
  }
}
void Flash() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> gas[i];
  }
  long long u, v, l;
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v >> l;
    --u, --v;
    adj[u].push_back(v), adj[v].push_back(u);
    len[make_pair(u, v)] = l, len[make_pair(v, u)] = l;
  }
  long long ans = -1;
  dfs(0, 0, ans);
  dfs2(0, 0, ans, -1000000000000000000LL);
  cout << ans << "\n";
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  ;
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    Flash();
  }
  return 0;
}
