#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

template <typename _tp> inline void cmax(_tp&A,const _tp&B){if(A < B) A = B;}
template <typename _tp> inline void cmin(_tp&A,const _tp&B){if(A > B) A = B;}

template <typename _tp> inline void read(_tp&x){
	char c11=getchar(),ob=0;x=0;
	while(c11!='-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;
}

const ll Inf = 2e18;
const int N = 201000;
struct Edge{int v,nxt;ll w;}a[N+N+N];
int head[N],Head[N],vs[N],w[N],id[N];
int n,_;

inline void ad(){
	static int x,y,z; read(x), read(y), read(z);
	a[++_].v = y, a[_].w = z, a[_].nxt = head[x], head[x] = _;
	a[++_].v = x, a[_].w = z, a[_].nxt = head[y], head[y] = _;
}

namespace dsu{
	int dad[N];
	int find(int x){return dad[x]? dad[x] = find(dad[x]): x;}
	bool check(int x,int y){return find(x) == find(y);}
	bool merge(int x,int y){
		static int p1,p2;
		if((p1 = find(x)) == (p2 = find(y))) return false;
		dad[p1] = p2; return true;
	}
}

namespace TD{
	int sz[N], rt, Mi, nn;
	void get_rt(int x,int las){
		sz[x] = 1;int mx = 0;
		for(int i=head[x];i;i=a[i].nxt)
			if(a[i].v!=las and !vs[a[i].v]){
				get_rt(a[i].v,x);
				sz[x] += sz[a[i].v];
				cmax(mx, sz[a[i].v]);
			}
		cmax(mx, nn - sz[x]);
		if(mx < Mi) Mi = mx, rt = x;
	}
	
	void Get_rt(int x,int xn){rt = 0, nn = xn, Mi = 2e9; get_rt(x,0);}
	
	void build(int x,int las){
		vs[x] = 1;
		a[++_].v = x, a[_].nxt = Head[las], Head[las] = _;
		get_rt(x,0);
		for(int i=head[x];i;i=a[i].nxt)
			if(!vs[a[i].v]){
				Get_rt(a[i].v,sz[a[i].v]);
				build(rt,x);
			}
	}
}

struct node{
	ll v;int id;
	inline node(){}
	inline node(const ll&V,const int&Id):v(V),id(Id){}
}tr[N], p[N], Mx, Mi, Fir[N], Sec[N];

node pre_fir[N], pre_sec[N];
node suf_fir[N], suf_sec[N];

inline void upd(node&A, node&B, node nw){
	if(nw.v < A.v) {
		if(nw.id == A.id) {A = nw; return ;}
		B = A, A = nw; return ;
	}
	if(nw.v < B.v)
		if(nw.id != A.id) B = nw;
}

void get_val(int x,int las,ll dep){
	upd(Mi, Mx, node(dep+w[x],id[x]));
	for(int i=head[x];i;i=a[i].nxt)
		if(a[i].v!=las and !vs[a[i].v])
			get_val(a[i].v,x,dep+a[i].w);
}

void cover(int x,int las,ll dep,node A,node B){
	if(id[x] != A.id and dep + A.v < p[x].v)
		p[x].v = dep + A.v, p[x].id = A.id;
	if(id[x] != B.id and dep + B.v < p[x].v)
		p[x].v = dep + B.v, p[x].id = B.id;
	for(int i=head[x];i;i=a[i].nxt)
		if(a[i].v!=las and !vs[a[i].v])
			cover(a[i].v,x,dep+a[i].w,A,B);
}

int to[N], to_w[N];

void work(int x){
	vs[x] = 1;
	int top = 0;
	for(int i=head[x];i;i=a[i].nxt)
		if(!vs[a[i].v]){
			Mi = node(w[x],id[x]), Mx = node(Inf,0);
			get_val(a[i].v,x,a[i].w);
			++top, to[top] = a[i].v, to_w[top] = a[i].w;
			Fir[top] = Mi, Sec[top] = Mx;
		}
	
	pre_fir[1] = Fir[1];
	pre_sec[1] = Sec[1];
	for(int i=2;i<=top;++i){
		pre_fir[i] = pre_fir[i-1];
		pre_sec[i] = pre_sec[i-1];
		upd(pre_fir[i], pre_sec[i], Fir[i]);
		upd(pre_fir[i], pre_sec[i], Sec[i]);
	}
	suf_fir[top] = Fir[top];
	suf_sec[top] = Sec[top];
	for(int i=top-1;i>=1;--i){
		suf_fir[i] = suf_fir[i+1];
		suf_sec[i] = suf_sec[i+1];
		upd(suf_fir[i], suf_sec[i], Fir[i]);
		upd(suf_fir[i], suf_sec[i], Sec[i]);
	}
	
	node A,B;
	for(int i=1;i<=top;++i){
		A = node(w[x],id[x]), B = node(Inf,0);
		if(i!=1) upd(A,B,pre_fir[i-1]);
		if(i!=1) upd(A,B,pre_sec[i-1]);
		if(i!=top) upd(A,B,suf_fir[i+1]);
		if(i!=top) upd(A,B,suf_sec[i+1]);
		cover(to[i],x,to_w[i],A,B);
	}
	
	if(top){
		A = pre_fir[top], B = pre_sec[top];
		if(id[x] != A.id and A.v < p[x].v)
			p[x].v = A.v, p[x].id = A.id;
		if(id[x] != B.id and B.v < p[x].v)
			p[x].v = B.v, p[x].id = B.id;
	}
	
	for(int i=Head[x];i;i=a[i].nxt)
		work(a[i].v);
}

int main(){
	read(n);
	for(int i=1;i<=n;++i)read(w[i]);
	for(int i=1;i<n;++i)ad();
	
	TD::build(1,0);
	
	int Tot = n; ll Ans = 0ll;
	while(Tot > 1){
		for(int i=1;i<=n;++i) id[i] = dsu::find(i), p[i].v = Inf, vs[i] = 0;
		work(a[Head[0]].v);
		for(int i=1;i<=n;++i) tr[i].v = Inf;
		for(int i=1,t;i<=n;++i){
			t = dsu::find(i);
			if(tr[t].v > w[i] + p[i].v)
				tr[t].v = p[i].v + w[i], tr[t].id = p[i].id;
		}
		for(int i=1;i<=n;++i)
			if(dsu::find(i) == i){
				if(dsu::check(i, tr[i].id)) continue;
				Ans += tr[i].v, dsu::merge(i, tr[i].id);
				--Tot;
			}
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 58624