#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int MAXN = 3e5 + 500;
const int MAXM = 1e6 + 5;
const int maxn = 1 << 19;
const long long mod = 1e9 + 7;
long long a[MAXN], dp[MAXN];
long long ans = 0;
vector<pair<int, long long>> v[MAXN];
long long dfs(int cur, int fa) {
  ans = max(ans, dp[cur]);
  for (int i = 0; i < v[cur].size(); i++) {
    int son = v[cur][i].first;
    if (son == fa) continue;
    dfs(son, cur);
    long long val = dp[son] - v[cur][i].second;
    ans = max(ans, dp[cur] + val);
    dp[cur] = max(dp[cur], a[cur] + val);
  }
  return ans;
}
int main() {
  int n, x, y, w;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    dp[i] = a[i];
  }
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d %d %d", &x, &y, &w);
    v[x].push_back({y, w});
    v[y].push_back({x, w});
  }
  printf("%lld\n", dfs(1, 0));
  return 0;
}
