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

typedef long long lint;
const int maxn = 200005;

int n, w[maxn], fa[maxn];

struct edge1
{
	int to, next, w;
} e[maxn * 2];
int h[maxn], tot;

struct edge2
{
	int u, v;
	lint w;
	bool operator < (const edge2 &a) const {
		return w < a.w;
	}
} E[maxn * 25];
int cnt;

int Siz, siz[maxn], mxsz[maxn], p, rt, vis[maxn];
lint dis[maxn];

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline void add(int u, int v, int w)
{
	e[++tot] = (edge1) {v, h[u], w}; h[u] = tot;
	e[++tot] = (edge1) {u, h[v], w}; h[v] = tot;
}

void getroot(int u, int fa)
{
	siz[u] = 1; mxsz[u] = 0;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa && !vis[v]) {
			getroot(v, u); siz[u] += siz[v];
			mxsz[u] = max(mxsz[u], siz[v]);
		}
	mxsz[u] = max(mxsz[u], Siz - siz[u]);
	if (mxsz[u] < mxsz[rt]) rt = u;
}

void dfs(int u, int fa)
{
	if (dis[u] + w[u] < dis[p] + w[p]) p = u;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa && !vis[v]) dis[v] = dis[u] + e[i].w, dfs(v, u);
}

void link(int u, int fa)
{
	if (u != p) E[++cnt] = (edge2) {u, p, w[u] + w[p] + dis[u] + dis[p]};
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa && !vis[v]) link(v, u);
}

void solve(int u)
{
	rt = 0; getroot(u, 0); u = rt; vis[u] = 1;
	p = u; dis[u] = 0; dfs(u, 0); link(u, 0);
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (!vis[v]) Siz = siz[v], solve(v);
}

inline int find(int x)
{
	if (!fa[x]) return x;
	return fa[x] = find(fa[x]);
}

int main()
{
	n = gi();
	for (int i = 1; i <= n; ++i) w[i] = gi();
	for (int u, v, i = 1; i < n; ++i) u = gi(), v = gi(), add(u, v, gi());
	
	Siz = n; mxsz[0] = n; solve(1);

	lint ans = 0;
	sort(E + 1, E + cnt + 1);
	for (int i = 1, j = 1; i < n; ++i) {
		while (find(E[j].u) == find(E[j].v)) ++j;
		fa[find(E[j].u)] = E[j].v; ans += E[j].w;
	}
	printf("%lld\n", ans);

	return 0;
}
