/*
2
1000000000 1000000000
2 1 1000000000
*/
#include <bits/stdc++.h>
using namespace std;
void print() { cout << '\n'; } template<class T, class ...U> void print(T x, U ...y) { cout << x << ' '; print(y...); }
typedef long long ll; const int N = 2e5 + 5, M = 1e9 + 7; typedef vector<int> vi; typedef vector<vi> vii; void Main();
int main(int argc, char **argv) {
  ios::sync_with_stdio(0), cin.tie(0); cout << setprecision(10) << fixed;
  #ifdef Zmm
  freopen((string(*(argv)).substr(2, string(*(argv)).size() - 6) + string(".cpp")).c_str(), "r", stdin); string x; cin >> x;
  #endif
  Main();
}
struct edge {
  ll v, w;
  bool operator<(const edge &e)const { return w > e.w; }
};
vector<edge> G[N], g[N];
namespace DFZ {
  int x[N], siz[N], RT, RTMAX, vis[N], SIZE;
  void getrt(int u, int fa) {
    int mx = 0;
    siz[u] = 1;
    for (edge &e : G[u]) if (e.v != fa && !vis[e.v]) {
      getrt(e.v, u);
      siz[u] += siz[e.v];
      mx = max(mx, siz[e.v]);
    }
    mx = max(mx, SIZE - siz[u]);
    if (mx < RTMAX) RTMAX = mx, RT = u;
  }
  int rt;
  pair<ll, int> diss[N];
  ll DIS;
  void getdis(int u, int fa, ll dis) {
    if (dis + x[u] < DIS) DIS = dis + x[u], rt = u;
    for (edge &e : G[u]) if (e.v != fa && !vis[e.v]) {
      getdis(e.v, u, dis + e.w);
    }
  }
  void build(int u, int fa, ll dis) {
    if (rt != u) g[rt].push_back({u, dis + x[u]}), g[u].push_back({rt, dis + x[u]});
    for (edge &e : G[u]) if (e.v != fa && !vis[e.v]) build(e.v, u, dis + e.w);
  }

  void dfz(int u) {
    vis[u] = 1;
    DIS = 0x3f3f3f3f3f3f3f3f;
    getdis(u, u, 0);
    build(u, u, DIS);
    for (edge &e : G[u]) if (!vis[e.v]) {
      RT = RTMAX = SIZE = siz[e.v];
      getrt(e.v, u);
      dfz(RT);
    }
  }
}
namespace Prim {
  bool vis[N];
  ll dis[N];
  ll prim(int n) {
    for (int i = 1; i <= n; i++) dis[i] = 0x3f3f3f3f3f3f3f3f;
    ll ans = 0;
    priority_queue<edge> q;
    q.push({1, 0});
    while (!q.empty()) {
      edge e = q.top();
      q.pop();
      if (vis[e.v]) continue;
      vis[e.v] = 1, ans += e.w;
      for (edge &ee : g[e.v]) if (!vis[ee.v]) {
        if (dis[ee.v] > ee.w) dis[ee.v] = ee.w, q.push({ee.v, ee.w});
      }
    }
    return ans;
  }
}
void Main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> DFZ::x[i];
  for (int i = 1, u, v, w; i < n; i++) cin >> u >> v >> w, G[u].push_back({v, w}), G[v].push_back({u, w});
  DFZ::RT = DFZ::RTMAX = DFZ::SIZE = n;
  DFZ::getrt(1, 1);
  DFZ::dfz(DFZ::RT);
  cout << Prim::prim(n) << '\n';
}