#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long w[n], deg[n], vis[n], max1[n];
  vector<vector<long long> > add(n);
  unordered_map<long long, long long> is_connected;
  unordered_map<long long, set<long long> > c;
  for (long long i = 0; i < n; i++) {
    cin >> w[i];
    deg[i] = 0;
    vis[i] = 0;
    max1[i] = 0;
  }
  long long a, b, ci;
  for (long long i = 0; i < n - 1; i++) {
    cin >> a >> b >> ci;
    --a;
    --b;
    deg[a]++;
    deg[b]++;
    c[a].insert(b);
    c[b].insert(a);
    is_connected[a * n + b] = ci;
    is_connected[b * n + a] = ci;
  }
  for (long long j = 0; j < n; j++) {
    long long i = j;
    while (deg[i] == 1) {
      long long sec = *(c[i].begin());
      long long temp =
          max((long long)0, w[i] + max1[i] - is_connected[i * n + sec]);
      add[sec].push_back(temp);
      max1[sec] = max(max1[sec], temp);
      deg[sec]--;
      deg[i]--;
      c[sec].erase(i);
      if (deg[sec] != 1) break;
      i = sec;
    }
  }
  for (long long i = 0; i < n; i++) {
    sort(add[i].begin(), add[i].end());
  }
  long long fans = 0;
  for (long long i = 0; i < n; i++) {
    long long id = 0;
    if (add[i].size() > 1) id = add[i][add[i].size() - 2];
    fans = max(fans, w[i] + max1[i] + id);
  }
  cout << fans;
}
