#include <bits/stdc++.h>
using namespace std;
int N;
signed long long W[303030];
vector<pair<int, int>> E[303030];
signed long long best[303030];
signed long long ma;
void dfs(int cur, int pre) {
  vector<signed long long> C;
  for (auto& e : E[cur])
    if (e.first != pre) {
      dfs(e.first, cur);
      if (best[e.first] - e.second > 0) C.push_back(best[e.first] - e.second);
    }
  C.push_back(0);
  C.push_back(0);
  sort((C.begin()), (C.end()));
  reverse((C.begin()), (C.end()));
  ma = max(ma, W[cur] + C[0] + C[1]);
  best[cur] = W[cur] + C[0];
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  for (i = 0; i < (N); i++) cin >> W[i];
  for (i = 0; i < (N - 1); i++) {
    cin >> x >> y >> r;
    E[x - 1].push_back({y - 1, r});
    E[y - 1].push_back({x - 1, r});
  }
  dfs(0, -1);
  cout << ma << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
