#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
template <class T>
inline void sort(T &a) {
  sort((a).begin(), (a).end());
}
template <class T>
inline void rsort(T &a) {
  sort((a).rbegin(), (a).rend());
}
template <class T>
inline void reverse(T &a) {
  reverse((a).begin(), (a).end());
}
template <class T, class U>
inline void checkmin(T &x, U y) {
  if (x > y) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
  if (x < y) x = y;
}
vector<vector<pair<int, int>>> G;
vector<int> w;
long long allans = 0;
long long dfs(int v, int p = -1) {
  long long ans = w[v];
  vector<long long> arr;
  for (auto &i : G[v])
    if (i.first != p) {
      long long ansi = dfs(i.first, v) - i.second;
      checkmax(ansi, 0);
      arr.push_back(ansi);
      checkmax(ans, ansi + w[v]);
    }
  sort(arr);
  if (int(arr.size()) > 1)
    checkmax(allans,
             w[v] + arr[int(arr.size()) - 1] + arr[int(arr.size()) - 2]);
  checkmax(allans, ans);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(7);
  srand(time(nullptr));
  long long n;
  cin >> n;
  G.resize(n);
  w.resize(n);
  for (auto &i : w) cin >> i;
  for (int i = 1; i < n; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    --u, --v;
    G[u].push_back({v, c});
    G[v].push_back({u, c});
  }
  dfs(0);
  cout << allans;
  return 0;
}
