#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long int paw(long long int a, long long int b);
long long int w[312345], ans = LLONG_MIN, c[312345];
vector<vector<int> > adj;
int u[312345], v[312345], vis[312345];
long long int dfs(int cur) {
  vis[cur] = 1;
  long long int temp, f_max = -10000000000000000, s_max = -10000000000000000;
  for (auto itr : adj[cur]) {
    if (vis[u[itr] ^ v[itr] ^ cur]) continue;
    temp = dfs(u[itr] ^ v[itr] ^ cur) - c[itr];
    if (temp >= f_max) {
      s_max = f_max;
      f_max = temp;
    } else if (temp >= s_max) {
      s_max = temp;
    }
  }
  ans = max(ans, f_max + w[cur]);
  ans = max(ans, f_max + s_max + w[cur]);
  return max(f_max + w[cur], w[cur]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, i, x, y, co;
  cin >> n;
  adj.resize(n + 10);
  for (i = 0; i < n; i++) {
    cin >> w[i + 1];
    ans = max(ans, w[i + 1]);
  }
  for (i = 0; i < n - 1; i++) {
    cin >> x >> y >> co;
    u[i] = x;
    v[i] = y;
    c[i] = co;
    adj[x].push_back(i);
    adj[y].push_back(i);
  }
  dfs(1);
  cout << ans << endl;
  return 0;
}
long long int paw(long long int a, long long int b) {
  long long int x = ((a) % 1000000007), ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * x) % 1000000007;
    x = (x * x) % 1000000007;
    b >>= 1;
  }
  return ans;
}
