#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 300000;
const int LOG = 20;

pair<ll , int> rmq[MAXN * 4];
ll dd[MAXN * 4];
ll x[MAXN];
int en[MAXN];
int tin[MAXN];
int up[LOG][MAXN];
ll hh[MAXN];
int tout[MAXN];
int tm1;
int n;
int gg[MAXN * 4];
vector<pair<int, ll> > eds[MAXN];
int pp[MAXN];
ll pc[MAXN];

const ll INF = 1e18;

void push(int v) {
	if (dd[v]) {
		rmq[v * 2 + 1].first += dd[v];
		dd[v * 2 + 1] += dd[v];
		rmq[v * 2 + 2].first += dd[v];
		dd[v * 2 + 2] += dd[v];
		dd[v] = 0;
	}
	if (gg[v] != -1) {
		gg[v * 2 + 1] = gg[v];
		gg[v * 2 + 2] = gg[v];
		gg[v] = -1;
	}
}

void sten(int v, int tl, int tr, int x) {
	if (tl + 1 == tr) {
		rmq[v] = make_pair(INF, tl);
		return;
	}
	int m = (tl + tr) >> 1;
	push(v);
	if (x < m)
		sten(v * 2 + 1, tl, m, x);
	else
		sten(v * 2 + 2, m, tr, x);
	rmq[v] = min(rmq[v * 2 + 1], rmq[v * 2 + 2]);
}

void sten(int x) {
	en[x] = 1;
	sten(0, 0, n, tin[x]);
}


int getgo(int v, int tl, int tr, int x) {
	if (gg[v] != -1)
		return gg[v];
	int m = (tl + tr) >> 1;
	if (x < m)
		return getgo(v * 2 + 1, tl, m, x);
	else
		return getgo(v * 2 + 2, m, tr, x);
}

void add(int v, int tl, int tr, int l, int r, ll d, int k) {
	if (r <= tl || tr <= l)
		return;
	if (l <= tl && tr <= r) {
		gg[v] = k;
		dd[v] += d;
		rmq[v].first += d;
		return;
	}
	push(v);
	int m = (tl + tr) >> 1;
	add(v * 2 + 1, tl, m, l, r, d, k);
	add(v * 2 + 2, m, tr, l, r, d, k);
	rmq[v] = min(rmq[v * 2 + 1], rmq[v * 2 + 2]);
}

int is_p(int a, int b) {
	return (tin[a] <= tin[b] && tin[b] < tout[a]);
}

int lca(int a, int b) {
	if (is_p(a, b))
		return a;
	if (is_p(b, a))
		return b;
	for (int i = LOG - 1; i >= 0; --i) {
		if (!is_p(up[i][a], b))
			a = up[i][a];
	}
	return up[0][a];
}

ll dis(int a, int b) {
	int x = lca(a, b);
	return hh[a] + hh[b] - 2 * hh[x];
}


int bc[MAXN];

void dfs1(int v, int p) {
	bc[tm1] = v;
	tin[v] = tm1++;
	for (auto e: eds[v]) {
		int u = e.first;
		if (u == p)
			continue;
		pp[u] = v;
		pc[u] = e.second;
		hh[u] = hh[v] + e.second;
		dfs1(u, v);
	}
	tout[v] = tm1;
}

void build(int v, int tl, int tr) {
	if (tl + 1 == tr) {
		rmq[v] = make_pair(0, tl);
		return;
	}
	int m = (tl + tr) >> 1;
	build(v * 2 + 1, tl, m);
	build(v * 2 + 2, m, tr);
	rmq[v] = min(rmq[v * 2 + 1], rmq[v * 2 + 2]);
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < 4 * n; ++i)
		gg[i] = -1;
	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;
		eds[a].push_back(make_pair(b, c));
		eds[b].push_back(make_pair(a, c));
	}
	int bst = 0;
	for (int i = 0; i < n; ++i)
		if (x[i] < x[bst])
			bst = i;
	pp[bst] = -1;
	dfs1(bst, -1);
	for (int i = 0; i < n; ++i)
		up[0][i] = pp[i];
	up[0][bst] = bst;
	for (int i = 1; i < LOG; ++i) {
		for (int j = 0; j < n; ++j)
			up[i][j] = up[i - 1][up[i - 1][j]];
	}
	for (int i = 0; i < n; ++i)
		en[i] = 0;
	build(0, 0, n);
	sten(bst);
	for (int i = 0; i < n; ++i) {
		if (!en[i]) {
			add(0, 0, n, tin[i], tin[i] + 1, x[i] + x[bst] + hh[i], bst);
		}
	}
	ll ans = 0;
	for (int i = 1; i < n; ++i) {
		ans += rmq[0].first;
		int a = bc[rmq[0].second];
		sten(a);
		int b = getgo(0, 0, n, tin[a]);
		int cur = a;
		int pr = -1;
		while ((!en[cur] || cur == a) && hh[a] - hh[cur] + x[a] + x[cur] < dis(b, cur) + x[cur] + x[b]) {
			add(0, 0, n, tin[cur], tin[cur] + 1, x[a] + hh[a] - hh[cur] - x[b] - dis(b, cur), a);
			for (auto e: eds[cur]) {
				int u = e.first;
				if (u != pr && hh[u] > hh[cur]) {
					add(0, 0, n, tin[u], tout[u], x[a] + hh[a] - hh[cur] - x[b] - dis(b, cur), a);
				}
			}
			pr = cur;
			cur = pp[cur];
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 80000