#include <bits/stdc++.h>
using namespace std;
struct Node {
  int v;
  int wei;
};
int n;
long long int ans;
long long int gasoline[300005];
bool visit[300005];
vector<Node> graph[300005];
long long int dfs(int u) {
  visit[u] = true;
  long long int cur = gasoline[u];
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i].v;
    int wei = graph[u][i].wei;
    if (!visit[v]) {
      long long int ret = dfs(v);
      ret = ret - wei;
      ans = max(ans, cur + ret);
      cur = max(cur, gasoline[u] + ret);
    }
  }
  return cur;
}
int main() {
  int u, v, wei;
  ans = -1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> gasoline[i];
    ans = max(ans, gasoline[i]);
  }
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> wei;
    graph[u].push_back({v, wei});
    graph[v].push_back({u, wei});
  }
  dfs(1);
  cout << ans << endl;
  return 0;
}
