#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ; 
struct E {
	int to, next, w ; 
} e[N << 1] ; 
struct node {
	int x, y, z ; 
} st[N * 20], sk[N] ;
int n, cnt, rt, top, top2, sum, head[N], fa[N], vis[N], w[N], dp[N], sz[N] ; 
bool cmp( node x, node y ) {
	return x.z < y.z ; 
} 
void add( int x, int y, int z ) {
	e[++ cnt] = (E){ y, head[x], z }, head[x] = cnt,
	e[++ cnt] = (E){ x, head[y], z }, head[y] = cnt ; 
}
void Getrt( int x, int fa ) {
	sz[x] = 1, dp[x] = 0 ; 
	Next( i, x ) {
		int v = e[i].to ; if( v == fa || vis[v] ) continue ; 
		Getrt(v, x), sz[x] += sz[v], dp[x] = max( dp[x], sz[v] ) ; 
	} dp[x] = max( dp[x], sum - sz[x] ) ; 
	if( dp[x] <= dp[rt] ) rt = x ; 
}
void Getd( int x, int fa, int d ) {
	sz[x] = 1, sk[++ top2] = (node){ x, 0, d + w[x] } ; 
	Next( i, x ) {
		int v = e[i].to ; if( v == fa || vis[v] ) continue ; 
		Getd( v, x, d + e[i].w ), sz[x] += sz[v] ; 
	}
}
void solve( int x ) {
	vis[x] = 1, top2 = 0, Getd( x, x, 0 ) ; 
	sort( sk + 1, sk + top2 + 1, cmp ) ;
	rep( i, 2, top2 ) st[++ top] = (node){ sk[i].x, sk[1].x, sk[i].z + sk[1].z } ; 
//	printf("solve-  %d %d\n", x, top ) ; 
	Next( i, x ) {
		int v = e[i].to ; if( vis[v] ) continue ; 
		sum = dp[rt = 0] = sz[v], Getrt( v, x ), solve(rt) ; 
	}
}
int fd( int x ) {
	return ( x == fa[x] ) ? x : fa[x] = fd(fa[x]) ; 
}
int merge( int x, int y ) {
	int u = fd(x), v = fd(y) ;
	if( u == v ) return 0 ; 
	fa[u] = v ; return 1 ; 
}
signed main()
{
	n = gi() ; int x, y, z ; 
	rep( i, 1, n ) w[i] = gi() ; 
	rep( i, 2, n ) x = gi(), y = gi(), z = gi(), add( x, y, z ) ; 
	dp[rt = 0] = sum = n, Getrt( 1, 1 ) ; 
	rep( i, 1, n ) fa[i] = i ; 
	solve(rt), sort( st + 1, st + top + 1, cmp ) ; int ans = 0 ;
	//rep( i, 1, top ) printf("%d %d %d\n", st[i].x, st[i].y, st[i].z ) ; 
	rep( i, 1, top ) {
		if( merge( st[i].x, st[i].y ) ) ans += st[i].z ; 
	}
	cout << ans << endl ;  
	return 0 ;
}