#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	ll x,y,w;
}b[4000010];
ll n,m,u,tot,val[500010],e[500010],hd[500010],nt[500010],sz[500010],
v[500010],rt,mx,mn,zo,ans,a[500010],pa[500010];
void build(ll x,ll y,ll w){
	tot++;
	e[tot]=y;val[tot]=w;
	nt[tot]=hd[x];hd[x]=tot;
}
void get(ll x,ll fa){
	ll i,now=0;
	sz[x]=1;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa||v[e[i]])continue;
		get(e[i],x);sz[x]+=sz[e[i]];
		now=max(now,sz[e[i]]);
	}
	now=max(now,zo-sz[x]);
	if(now<mx)mx=now,rt=x;
}
void dfs(ll x,ll fa,ll dep){
	ll i;
	if(a[x]+dep<mn)mn=a[x]+dep,u=x;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa||v[e[i]])continue;
		dfs(e[i],x,dep+val[i]);
	}
}
void link(ll x,ll fa,ll dep){
	ll i;
	b[++m].x=x;b[m].y=u;b[m].w=dep+a[x]+mn;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa||v[e[i]])continue;
		link(e[i],x,dep+val[i]);
	}
}
void divide(ll x){
	ll i;
	v[x]=1;
	mn=1e18;
	dfs(x,0,0);link(x,0,0);
	for(i=hd[x];i;i=nt[i]){
		if(v[e[i]])continue;
		zo=mx=sz[e[i]];get(e[i],x);
		divide(rt);
	}
}
bool cmp(aaa a,aaa b){
	return a.w<b.w;
}
ll find(ll x){
	if(x==pa[x])return x;
	return pa[x]=find(pa[x]);
}
int main(){
	ll i,x,y,w;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(i=1;i<n;i++){
		scanf("%lld%lld%lld",&x,&y,&w);
		build(x,y,w);build(y,x,w);
	}
	zo=mx=n;
	get(1,0);
	divide(rt);
	for(i=1;i<=n;i++)pa[i]=i;
	sort(b+1,b+m+1,cmp);
	for(i=1;i<=m;i++){
		x=find(b[i].x);y=find(b[i].y);
		if(x!=y){
			pa[x]=y;ans+=b[i].w;
		}
	}
	printf("%lld",ans);
}
/*
确实不会... 
*/