#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const LL OO = 0x3f3f3f3f3f3f3f3fLL;
const int oo = 0x3f3f3f3f;

const int maxn = 200100;

int n;
int a[maxn + 5];
vector<pair<int, int> > adj[maxn + 5];

int fa[maxn + 5];

int pa[maxn + 5];

int get(int x) { return pa[x] == x ? x : pa[x] = get(pa[x]); }

int seq[maxn + 5], seqn = 0;

void dfs(int x, int f = -1)
{
	seq[seqn++] = x;
	for (auto y : adj[x]) if (y.x != f)
	{
		dfs(y.x, x);
	}
}

pair<LL, int> up[maxn + 5], up_all[maxn + 5];
pair<LL, int> down[maxn + 5], down_all[maxn + 5];

pair<LL, pair<int, int> > Min[maxn + 5];

LL ans = 0;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n)
	{
		scanf("%d", a + i);
	}
	REP(i, 0, n - 1)
	{
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z), --x, --y;
		adj[x].pb(mp(y, z));
		adj[y].pb(mp(x, z));
	}
	seqn = 0;
	dfs(0);
	REP(i, 0, n) pa[i] = i;
	ans = 0;
	while (1)
	{
		bool isover = 1;
		REP(i, 0, n) if (get(i) != get(0))
		{
			isover = 0;
			break;
		}
		if (isover) break;
		REP(i, 0, n) up[i] = up_all[i] = down[i] = down_all[i] = mp(OO, -1);
		for (int i = n - 1; i >= 0; --i)
		{
			int x = seq[i];
			chkmin(down_all[x], mp((LL)a[x], x));
			for (auto y : adj[x]) if (y.x != fa[x])
			{
				chkmin(down_all[x], mp(down_all[y.x].x + y.y, down_all[y.x].y));
				if (get(y.x) != get(x))
				{
					chkmin(down[x], mp(down_all[y.x].x + y.y, down_all[y.x].y));
				}
				else
				{
					chkmin(down[x], mp(down[y.x].x + y.y, down[y.x].y));
				}
			}
		}
		REP(i, 0, n)
		{
			int x = seq[i];
			chkmin(up_all[x], mp((LL)a[x], x));
			vector<pair<int, int> > chd;
			for (auto y : adj[x]) if (y.x != fa[x]) chd.pb(y);
			REP(j, 0, 2)
			{
				pair<LL, int> tmp = up[x];
				pair<LL, int> tmp_all = up_all[x];
				for (auto u : chd)
				{
					chkmin(up_all[u.x], mp(tmp_all.x + u.y, tmp_all.y));
					if (get(u.x) != get(x))
					{
						chkmin(up[u.x], mp(tmp_all.x + u.y, tmp_all.y));
						chkmin(tmp, mp(down_all[u.x].x + u.y, down_all[u.x].y));
					}
					else
					{
						chkmin(up[u.x], mp(tmp.x + u.y, tmp.y));
						chkmin(tmp, mp(down[u.x].x + u.y, down[u.x].y));
					}
					chkmin(tmp_all, mp(down_all[u.x].x + u.y, down_all[u.x].y));
				}
				reverse(ALL(chd));
			}
		}
		vector<pair<LL, pair<int, int> > > all_e;
		REP(i, 0, n) Min[i] = mp(OO, mp(-1, -1));
		REP(i, 0, n)
		{
			auto tmp = min(up[i], down[i]);
			tmp.x += a[i];
			chkmin(Min[get(i)], mp(tmp.x, mp(tmp.y, i)));
		}
		REP(i, 0, n) if (pa[i] == i && ~Min[i].y.x) all_e.pb(Min[i]);
		sort(ALL(all_e));
		for (auto u : all_e)
		{
			int x = u.y.x, y = u.y.y;
			x = get(x), y = get(y);
			if (x != y)
			{
				pa[x] = y; ans += u.x;
			}
		}
		debug("%lld\n", ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 45556