// Original C++ solution (slower):
#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <vector>

#include <cstring>

#define SIZE 200005

#define INF 10000000000000000LL

 

using namespace std;

typedef long long int ll;

typedef pair <int,int> P;

typedef pair <ll,P> PP;

 

struct edge

{

	int to;

	ll cost;

	edge(int to=0,ll cost=0):to(to),cost(cost){}

};

struct UF

{

	int par[SIZE],rank[SIZE];

	

	void init(int n)

	{

		for(int i=0;i<n;i++)

		{

			par[i]=i;

			rank[i]=0;

		}

	}

	int find(int x)

	{

		if(par[x]==x) return x;

		return par[x]=find(par[x]);

	}

	void unite(int x,int y)

	{

		x=find(x);

		y=find(y);

		if(x==y) return;

		if(rank[x]<rank[y]) par[x]=y;

		else

		{

			par[y]=x;

			if(rank[x]==rank[y]) rank[x]++;

		}

	}

	bool same(int x,int y)

	{

		return find(x)==find(y);

	}

};

UF uf;

vector <edge> vec[SIZE];

ll X[SIZE];

int v1[SIZE],v2[SIZE];

ll d1[SIZE],d2[SIZE];

int id[SIZE],ch[SIZE];

int now_id;

 

void dfs(int v=0,int p=-1)

{

	id[v]=now_id++;

	d1[v]=d2[v]=INF;

	v1[v]=v2[v]=-1;

	for(int i=0;i<vec[v].size();i++)

	{

		edge e=vec[v][i];

		if(e.to!=p)

		{

			dfs(e.to,v);

			ll vl=d1[e.to]+e.cost;

			int vv=v1[e.to];

			if(vl>e.cost+X[e.to])

			{

				vl=e.cost+X[e.to];

				vv=e.to;

			}

			if(vl<d1[v])

			{

				swap(vl,d1[v]);

				swap(vv,v1[v]);

			}

		}

	}

	ch[v]=now_id;

}

void make(int v=0,int p=-1)

{

	for(int i=0;i<vec[v].size();i++)

	{

		edge e=vec[v][i];

		if(e.to!=p)

		{

			ll vl=d1[v]+e.cost;

			int vv=v1[v];

			if(id[e.to]<=id[vv]&&id[vv]<ch[e.to])

			{

				vl=d2[v]+e.cost;

				vv=v2[v];

			}

			if(vl>e.cost+X[v])

			{

				vl=e.cost+X[v];

				vv=v;

			}

			if(vl<d1[e.to])

			{

				swap(vl,d1[e.to]);

				swap(vv,v1[e.to]);

			}

			make(e.to,v);

		}

	}

}

int A[SIZE],B[SIZE];

ll C[SIZE];

int main()

{

	int n;

	scanf("%d",&n);

	for(int i=0;i<n;i++) scanf("%lld",&X[i]);

	for(int i=0;i<n-1;i++)

	{

		int a,b;

		ll c;

		scanf("%d %d %lld",&a,&b,&c);a--,b--;

		vec[a].push_back(edge(b,c));

		vec[b].push_back(edge(a,c));

		A[i]=a,B[i]=b,C[i]=c;

	}

	dfs();

	make();

	uf.init(n+2);

	ll ret=0;

	for(int i=0;i<n;i++)

	{

		if(v1[v1[i]]==i&&i<v1[i]) continue;

		ret+=d1[i]+X[i];

		uf.unite(i,v1[i]);

	}

	for(int i=0;i<n-1;i++)

	{

		if(!uf.same(A[i],B[i]))

		{

			ret+=min(X[A[i]],d1[A[i]]);

			ret+=min(X[B[i]],d1[B[i]]);

			ret+=C[i];

		}

	}

	printf("%lld\n",ret);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define N 300010

#define inf 1000000000000000ll

using namespace std;

typedef long long ll;

inline int read()

{

	int x=0,f=1; char ch=getchar();

	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}

	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}

	return x*f;

}

struct edge

{

	int u,v,next;

	ll w;

}vs[N<<1];

int n,ee,st[N],bg[N],ed[N],las;

int V1[N],V2[N];

ll F1[N],F2[N],vl[N];

inline void addedge(int u,int v,int w)

{

	vs[++ee].v=v; 

	vs[ee].w=w; vs[ee].u=u;

	vs[ee].next=st[u];st[u]=ee;

}

inline void dfs(int rt,int pr)

{

	bg[rt]=las++;

	V1[rt]=V2[rt]=-1;

	F1[rt]=F2[rt]=inf;

	for(int i=st[rt];i;i=vs[i].next)

	{

		if(vs[i].v==pr) continue;

		dfs(vs[i].v,rt);

		int xx=V1[vs[i].v]; ll yy=F1[vs[i].v]+vs[i].w;

		if(yy>vl[vs[i].v]+vs[i].w)

			yy=vl[vs[i].v]+vs[i].w,

			xx=vs[i].v;

		if(F1[rt]>yy) swap(yy,F1[rt]),swap(xx,V1[rt]);

		if(F2[rt]>yy) swap(yy,F2[rt]),swap(xx,V2[rt]);

	}

	ed[rt]=las;

}

inline void DFS(int rt,int pr)

{

	for(int i=st[rt];i;i=vs[i].next)

	{

		if(vs[i].v==pr) continue;

		int xx=V1[rt]; ll yy=F1[rt]+vs[i].w;

		if(bg[vs[i].v]<=bg[xx]&&bg[xx]<ed[vs[i].v])

		{

			xx=V2[rt]; yy=F2[rt]+vs[i].w;

		}

		if(yy>vs[i].w+vl[rt])

			yy=vl[rt]+vs[i].w, 

			xx=rt;

		if(F1[vs[i].v]>yy) swap(yy,F1[vs[i].v]),swap(xx,V1[vs[i].v]);

		if(F2[vs[i].v]>yy) swap(yy,F2[vs[i].v]),swap(xx,V2[vs[i].v]);

		DFS(vs[i].v,rt);

	}

}

int fa[N];

inline int getfa(int x)

{

	return fa[x]==x? x:fa[x]=getfa(fa[x]);

}

int main()

{

	n=read(); for(int i=1;i<=n;i++)

		vl[i]=read();

	for(int i=1;i<n;i++)

	{

		int u=read(), v=read(), w=read();

		addedge(u,v,w); addedge(v,u,w); 

	}dfs(1,0); DFS(1,0);

	for(int i=1;i<=n;i++) fa[i]=i;

	ll Ans=0;

	for(int i=1;i<=n;i++)

	{

		if(V1[V1[i]]==i&&i>V1[i]) continue;

		Ans+=F1[i]+vl[i];

		int f1=getfa(i),f2=getfa(V1[i]);

		fa[f1]=f2;

	}

	for(int i=1;i<n;i++)

	{

		if(getfa(vs[i<<1].u)==getfa(vs[i<<1].v)) continue;

		Ans+=min(vl[vs[i<<1].u],F1[vs[i<<1].u]);

		Ans+=min(vl[vs[i<<1].v],F1[vs[i<<1].v]);

		Ans+=vs[i<<1].w;

	}

	cout << Ans << endl;

	return 0 ;

}

// Fastest known solution for this problem: