#include <bits/stdc++.h>
const int64_t MAX_N = 3e5;
int64_t maxAns = 0;
class Tree {
 private:
  struct Node {
    bool isVisited;
    int64_t id, w, dp;
    std::vector<std::pair<Node *, int64_t> > v;
  };
  int64_t cntNodes;
  Node nodes[MAX_N + 5];
  void Dfs(Node *nd) {
    nd->isVisited = true;
    nd->dp = nd->w;
    std::vector<int64_t> aux = {0, 0};
    for (auto &x : nd->v) {
      Node *nxt = x.first;
      if (!nxt->isVisited) {
        Dfs(nxt);
        nd->dp = std::max(nd->dp, nxt->dp + nd->w - x.second);
        aux.push_back(nxt->dp - x.second);
      }
    }
    std::sort(aux.begin(), aux.end());
    maxAns =
        std::max(maxAns, aux[aux.size() - 1] + aux[aux.size() - 2] + nd->w);
  }

 public:
  void Init(int64_t pCntNodes) {
    cntNodes = pCntNodes;
    for (int64_t i = 1; i <= cntNodes; i++) {
      nodes[i].id = i;
    }
  }
  void AddEdge(int64_t x, int64_t y, int64_t w) {
    nodes[x].v.push_back({&nodes[y], w});
    nodes[y].v.push_back({&nodes[x], w});
  }
  void SetW(int64_t x, int64_t w) { nodes[x].w = w; }
  void Solve() { Dfs(&nodes[1]); }
};
Tree t;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int64_t n;
  std::cin >> n;
  t.Init(n);
  for (int64_t i = 0; i < n; i++) {
    int64_t w;
    std::cin >> w;
    t.SetW(i + 1, w);
  }
  for (int64_t i = 0; i < n - 1; i++) {
    int64_t x, y, w;
    std::cin >> x >> y >> w;
    t.AddEdge(x, y, w);
  }
  t.Solve();
  std::cout << maxAns << '\n';
}
