#include <bits/stdc++.h>
using namespace std;
vector<long long> dist[300010], road[300010];
long long city[300010], ans = 0, dp[300010] = {0};
void dfs(long long i, long long fa) {
  ans = max(ans, dp[i]);
  for (long long j = 0; j < road[i].size(); ++j) {
    if (fa == road[i][j]) continue;
    dfs(road[i][j], i);
    ans = max(ans, dp[i] + dp[road[i][j]] - dist[i][j]);
    dp[i] = max(dp[i], city[i] + dp[road[i][j]] - dist[i][j]);
  }
}
int main() {
  int n, a, b, c;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &city[i]);
    dp[i] = city[i];
  }
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    road[a].push_back(b);
    road[b].push_back(a);
    dist[a].push_back(c);
    dist[b].push_back(c);
  }
  dfs(1, 0);
  cout << ans;
}
