#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;


typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(){}
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

pair<Weight, Edges> VoronoiMST(const Graph &G1,const vint &S,Graph &G2){
  int N = S.size();
  G2.resize(N);
  Weight total=0;
  Edges F;
  priority_queue<Edge> Q;
  vint dist(G1.size(),0),used(G1.size(),0),from(G1.size(),-1);
  repeat(i,N){
    Q.push({-1,S[i],0});
    from[S[i]]=i;
  }
  int cnt=1;
  while(!Q.empty()){
    Edge e=Q.top();Q.pop();
    int v = e.dst;
    if(used[v]){
      if(used[v]>used[e.src]){
        total += dist[v]+e.weight;
        F.push_back({from[v],from[e.src],dist[v]+e.weight});
        G2[from[v]].push_back({from[v],from[e.src],dist[v]+e.weight});
        G2[from[e.src]].push_back({from[e.src],from[v],dist[v]+e.weight});
      }
      continue;
    }
    used[v]=cnt;
    cnt++;
    dist[v] = e.weight;
    from[v] = from[e.src];
    for(Edge f:G1[v]){
      Q.push({v,f.dst,dist[v]+f.weight});
    }
  }
  return make_pair(total,F);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  Graph G(N*2);
  repeat(i,N){
    Weight x;cin>>x;
    G[i].push_back({(int)i,(int)(N+i),x});
    G[N+i].push_back({(int)(N+i),(int)i,x});
  }
  repeat(i,N-1){
    int A,B;Weight C;
    cin>>A>>B>>C;
    A--;B--;
    G[A].push_back({A,B,C});
    G[B].push_back({B,A,C});
  }
  vint S(N);
  repeat(i,N){
    S[i]=N+i;
  }
  Graph g;
  cout << VoronoiMST(G,S,g).first << endl;
  return 0;
}
