#include <bits/stdc++.h>
using namespace std;
int n;
long long w[500000 + 1], f[500000 + 1], g[500000 + 1];
vector<int> a[500000 + 1], c[500000 + 1];
bool visited[500000 + 1];
void readData() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> w[i];
  int x, y, z;
  for (int i = 1; i < n; i++) {
    cin >> x >> y >> z;
    a[x].push_back(y);
    a[y].push_back(x);
    c[x].push_back(z);
    c[y].push_back(z);
  }
}
void dfs(int k) {
  visited[k] = true;
  int x;
  long long m1 = 0, m2 = 0, y;
  f[k] = w[k];
  g[k] = w[k];
  for (int i = 0; i < a[k].size(); i++) {
    x = a[k][i];
    if (visited[x] == false) {
      dfs(x);
      y = g[x] - c[k][i];
      g[k] = max(g[k], g[x] + w[k] - c[k][i]);
      f[k] = max(f[k], f[x]);
      if (y > m1) {
        m2 = m1;
        m1 = y;
      } else {
        if (y > m2) m2 = y;
      }
    }
  }
  f[k] = max(f[k], m1 + m2 + w[k]);
}
void solve() {
  dfs(1);
  cout << f[1];
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  readData();
  solve();
  return 0;
}
