#include <bits/stdc++.h>
using namespace std;
const int max_n = 3e5 + 55;
vector<pair<int, long long> > V[max_n];
long long result = 0;
long long n, a, b, c;
long long annn[max_n];
long long dfs(long long now, long long sub, long long pre) {
  set<long long> st;
  for (auto i : V[now])
    if (i.first != pre) st.insert(dfs(i.first, i.second, now));
  if (st.empty())
    return max(0LL, annn[now] - sub);
  else if (st.size() == 1)
    result = max(result, annn[now] + *prev(st.end()));
  else
    result = max(result, annn[now] + *prev(st.end()) + *prev(prev(st.end())));
  return max(0LL, *prev(st.end()) + annn[now] - sub);
}
int32_t main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", annn + i);
  for (int i = 1; i < n; i++)
    scanf("%lld%lld%lld", &a, &b, &c), V[a].push_back(make_pair(b, c)),
        V[b].push_back(make_pair(a, c));
  result = *max_element(annn + 1, annn + 1 + n);
  dfs(1, 0, -1);
  cout << result << endl;
  return 0;
}
