#include <bits/stdc++.h>
using namespace std;
struct Edge {
  Edge(int u, int v, int c) : u(u), v(v), c(c) {}
  int u, v, c;
  int another(int cur) {
    if (u == cur) {
      return v;
    }
    return u;
  }
};
class Solver {
 public:
  void solve() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    gas.resize(n);
    connect.resize(n);
    parent.resize(n, -1);
    edges.reserve(n);
    for (int i = 0; i < n; ++i) {
      cin >> gas[i];
    }
    for (int i = 0; i < n - 1; i++) {
      int u, v, c;
      cin >> u >> v >> c;
      --u;
      --v;
      edges.emplace_back(u, v, c);
      connect[u].push_back(i);
      connect[v].push_back(i);
    }
    dfs(0, -1);
    cout << max_gain << endl;
  }
  long long dfs(int cur, int parent_edge) {
    int cur_gain = gas[cur];
    long long max1 = 0, max2 = 0;
    for (int next_edge : connect[cur]) {
      if (next_edge == parent_edge) {
        continue;
      }
      long long res =
          dfs(edges[next_edge].another(cur), next_edge) - edges[next_edge].c;
      if (res > max1) {
        max2 = max1;
        max1 = res;
      } else if (res > max2) {
        max2 = res;
      }
    }
    long long cur_max = cur_gain;
    if (max1 > 0) {
      cur_max += max1;
      if (max2 > 0) {
        cur_max += max2;
      }
    }
    max_gain = max(max_gain, cur_max);
    return (max1 > 0) ? (cur_gain + max1) : cur_gain;
  }
  vector<int> gas;
  int n;
  long long max_gain = 0;
  vector<Edge> edges;
  vector<vector<int>> connect;
  vector<int> parent;
};
int main() {
  Solver sol;
  sol.solve();
  return 0;
}
