#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 X[MAXN];
struct node {
    int to,next;int64 val;
}E[MAXN * 2];
int head[MAXN],sumE;
int que[MAXN],ql,qr,fa[MAXN],siz[MAXN],son[MAXN];
int64 dis[MAXN];
pair<int64,int> pre[MAXN],suf[MAXN];
vector<int> ver[MAXN];
bool vis[MAXN];
struct Enode {
    int u,v;int64 c;
    friend bool operator < (const Enode &a,const Enode &b) {
	return a.c < b.c;
    }
}edge[MAXN * 30];
int tot;
void add(int u,int v,int64 c) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    E[sumE].val = c;
    head[u] = sumE;
}
void Init() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(X[i]);
    int a,b;int64 c;
    for(int i = 1 ; i < N ; ++i) {
	read(a);read(b);read(c);
	add(a,b,c);add(b,a,c);
    }
}
int getfa(int u) {
    return fa[u] == u ? u : fa[u] = getfa(fa[u]);
}
int Calc(int st) {
    que[ql = qr = 1] = st;
    fa[st] = 0;dis[st] = 0;
    while(ql <= qr) {
	int u = que[ql++];
	siz[u] = 1;son[u] = 0;
	for(int i = head[u] ; i ; i = E[i].next) {
	    int v = E[i].to;
	    if(v != fa[u] && !vis[v]) {
		que[++qr] = v;
		fa[v] = u;
	    }
	}
    }
    int res = que[qr];
    for(int i = qr ; i >= 1 ; --i) {
	int u = que[i];
	if(fa[u]) {son[fa[u]] = max(son[fa[u]],siz[u]);siz[fa[u]] += siz[u];}
	son[u] = max(son[u],qr - siz[u]);
	if(son[u] < son[res]) res = u; 
    }
    return res;
}
void dfs(int u) {
    int G = Calc(u);
    vis[G] = 1;
    int cnt = 0;
    dis[G] = 0;
    for(int i = head[G] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(!vis[v]) {
	    ++cnt;
	    ver[cnt].clear();
	    ver[cnt].pb(v);
	    fa[v] = G;dis[v] = dis[G] + E[i].val;
	    int s = 0;pair<int64,int> val = mp(dis[v] + X[v],v);
	    while(s < ver[cnt].size()) {
		int n = ver[cnt][s];++s;
		for(int k = head[n] ; k ; k = E[k].next) {
		    int h = E[k].to;
		    if(!vis[h] && h != fa[n]) {
			fa[h] = n;
			ver[cnt].pb(h);
			dis[h] = dis[n] + E[k].val;
			val = min(mp(dis[h] + X[h],h),val);
		    }
		}
	    }
	    pre[cnt] = val;
	    suf[cnt] = val;
	}
    }
    pre[0] = mp(1e18,0);
    for(int i = 1 ; i <= cnt ; ++i) pre[i] = min(pre[i - 1],pre[i]);
    suf[cnt + 1] = mp(1e18,0);
    for(int i = cnt ; i >= 1 ; --i) suf[i] = min(suf[i + 1],suf[i]);
    for(int i = 1 ; i <= cnt ; ++i) {
	pair<int64,int> t = min(pre[i - 1],suf[i + 1]);
	t = min(t,mp(X[G],G));
	for(auto v : ver[i]) {
	    edge[++tot] = (Enode){v,t.se,t.fi + dis[v] + X[v]};
	}
    }
    edge[++tot] = (Enode){G,pre[cnt].se,pre[cnt].fi + dis[G] + X[G]};
    for(int i = head[G] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(!vis[v]) dfs(v);
    }
}
void Solve() {
    dfs(1);
    sort(edge + 1,edge + tot + 1);
    for(int i = 1 ; i <= N ; ++i) fa[i] = i;
    int64 ans = 0;
    int cnt = 0;
    for(int i = 1 ; i <= tot ; ++i) {
	if(getfa(edge[i].u) != getfa(edge[i].v)) {
	    ans += edge[i].c;
	    fa[getfa(edge[i].u)] = getfa(edge[i].v);
	    ++cnt;
	    if(cnt == N - 1) break;
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
    return 0;
}


Measured memory_bytes: 78328