#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();
typedef long long ll; typedef double db;
const int N = 2e5 + 5, M = 1e9 + 7;

int a[N];
struct edge {
  int u, v, w;
} G[N * 2];
int head[N], nxt[N * 2], tot = 1;
void add(int u, int v, int w) {
  G[++tot] = {u, v, w};
  nxt[tot] = head[u];
  head[u] = tot;
}

bool vis[N * 2];
int mw, mwv;
void get_edge(int u, int f) {
  for (int i = head[u]; i; i = nxt[i]) {
    if (vis[i] || vis[i^1] || G[i].v == f) continue;
    if (G[i].w > mw) {
      mw = G[i].w;
      mwv = i;
    }
    get_edge(G[i].v, u);
  }
}
int get_siz(int u, int f) {
  int siz = 1;
  for (int i = head[u]; i; i = nxt[i]) {
    if (vis[i] || vis[i^1] || G[i].v == f) continue;
    siz += get_siz(G[i].v, u);
  }
  return siz;
}
ll dis[N], mdis;
void get_min(int u, int f) {
  mdis = min(mdis, (ll)dis[u] + a[u]);
  for (int i = head[u]; i; i = nxt[i]) {
    if (vis[i] || vis[i^1] || G[i].v == f) continue;
    dis[G[i].v] = dis[u] + G[i].w;
    get_min(G[i].v, u);
  }
}

ll solve(int u) {
  int n = get_siz(u, 0);
  //cout << n << endl;
  if (n == 1) return 0;
  if (n == 2) {
    for (int i = head[u]; i; i = nxt[i]) {
      if (vis[i] || vis[i^1]) continue;
      return (ll)a[G[i].v] + G[i].w + a[u];
    }
  }
  mw = 0, mwv = 0;
  get_edge(u, 0);
  int mid = mwv;
  ll ans = 0;
  vis[mid] = 1;
  dis[G[mid].v] = dis[G[mid].u] = 0;
  mdis = a[G[mid].v];
  get_min(G[mid].v, 0);
  ans += mdis;
  // cout << G[mid].w << ' ' << mdis << ' ' << G[mid].v << endl;
  mdis = a[G[mid].u];
  get_min(G[mid].u, 0);
  // cout << mdis << ' ' << G[mid].u << endl;
  ans += mdis;
  return ans + G[mid].w + solve(G[mid].u) + solve(G[mid].v);
}

int main() {
  int n; cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int u, v, w;
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> w;
    add(u, v, w);
    add(v, u, w);
  }
  cout << solve(1) << '\n';
}
