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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=214514;

struct Edge{
	int to,dist,idx;
};
vector<Edge> tree[Nmax];
bool vRem[Nmax];

int TreeSize(int v,int p){
	int ret=1;
	for(auto e:tree[v])if(e.to!=p&&!vRem[e.to])
		ret+=TreeSize(e.to,v);
	return ret;
}

int FindCentroid(int v,int p,int s){
	int ret=1,mx=0;
	for(auto e:tree[v])if(e.to!=p&&!vRem[e.to]){
		int f=FindCentroid(e.to,v,s);
		if(f<=0)
			return f;
		else{
			ret+=f;
			mx=max(mx,f);
		}
	}
	mx=max(mx,s-ret);
	if(mx*2<=s)
		return -v;
	else
		return ret;
}

int x[Nmax];
struct ResEdge{
	int a,b,c;
	bool operator<(const ResEdge&rhs)const{
		return c<rhs.c;
	}
};
vector<ResEdge> resEdges;

struct Data{
	int d,g,i;
};
void dfs(int v,int p,int d,int g,vector<Data>&dt){
	dt.PB(Data{d+x[v],g,v});
	for(auto e:tree[v])if(e.to!=p&&!vRem[e.to])
		dfs(e.to,v,d+e.dist,g,dt);
}
void Solve(int root){
	int ts=TreeSize(root,-1);
	if(ts==1)
		return;
	root=-FindCentroid(root,-1,ts);
	
	vector<Data> dt;
	int g=0;
	dt.PB(Data{x[root],g++,root});
	for(auto e:tree[root])if(!vRem[e.to])
		dfs(e.to,root,e.dist,g++,dt);
	
	int mi=-1;
	REP(i,dt.size())
		if(mi==-1||dt[mi].d>dt[i].d)
			mi=i;
		
	int mg=dt[mi].g;
	REP(i,dt.size())
		if(dt[i].g!=mg)
			resEdges.PB(ResEdge{dt[i].i,dt[mi].i,dt[i].d+dt[mi].d});
	
	mi=-1;
	REP(i,dt.size())
		if(dt[i].g!=mg)
			if(mi==-1||dt[mi].d>dt[i].d)
				mi=i;
	
	REP(i,dt.size())
		if(dt[i].g==mg)
			resEdges.PB(ResEdge{dt[i].i,dt[mi].i,dt[i].d+dt[mi].d});
	
	vRem[root]=true;
	for(auto e:tree[root])if(!vRem[e.to])
		Solve(e.to);
}

struct UnionFind{
	vi rank,par;
	void Init(int n){
		rank.assign(n,0);
		par.assign(n,-1);
	}
	int Find(int i){
		return par[i]==-1?i:(par[i]=Find(par[i]));
	}
	bool Same(int a,int b){
		return Find(a)==Find(b);
	}
	bool Unite(int a,int b){
		a=Find(a);
		b=Find(b);
		if(a==b)
			return false;
		if(rank[a]<rank[b])
			swap(a,b);
		par[b]=a;
		if(rank[a]==rank[b])
			rank[a]++;
		return true;
	}
};

signed main(){
	int n=read();
	REP(i,n)x[i]=read();
	REP(i,n-1){
		int a=read()-1,b=read()-1,c=read();
		tree[a].PB(Edge{b,c,i});
		tree[b].PB(Edge{a,c,i});
	}
	Solve(0);
	
	UnionFind uf;uf.Init(n);
	sort(ALL(resEdges));
	int ans=0;
	for(auto e:resEdges)
		if(!uf.Same(e.a,e.b)){
			ans+=e.c;
			uf.Unite(e.a,e.b);
		}
	cout<<ans<<endl;
}

Measured memory_bytes: 148448