#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
int v[200001];

struct _edge {
    int x, c;
    _edge(int x, int c) : x(x), c(c) {}
};

vector<_edge> edge[200001];

struct _es {
    int a, b;
    llong c;
    bool operator<(const _es &e) const {
        return c < e.c;
    }
    _es(int a, int b, llong c) : a(a), b(b), c(c) {}
};
vector<_es> es;

int del[200001];
int sz[200001];
llong dist[200001];

void dfs(int x, int p) {
    sz[x] = 1;
    for (_edge i : edge[x]) {
        if (i.x == p) continue;
        if (del[i.x]) continue;
        dfs(i.x, x);
        sz[x] += sz[i.x];
    }
}

pll dfs2(int x, int p) {
    pll ret(dist[x] + v[x], x);
    for (_edge i : edge[x]) {
        if (i.x == p) continue;
        if (del[i.x]) continue;
        dist[i.x] = dist[x] + i.c;
        ret = min(ret, dfs2(i.x, x));
    }
    return ret;
}

void dfs3(int x, int p, llong d, int t) {
    es.emplace_back(x, t, d + dist[x] + v[x]);
    for (_edge i : edge[x]) {
        if (i.x == p) continue;
        if (del[i.x]) continue;
        dfs3(i.x, x, d, t);
    }
}

void centroid(int x) {
    dfs(x, 0);
    int s = sz[x], p = 0, loop = 1;
    while (loop) {
        loop = 0;
        for (_edge i : edge[x]) {
            if (i.x == p) continue;
            if (del[i.x]) continue;
            if (s < (sz[i.x] << 1)) {
                loop = 1;
                p = x;
                x = i.x;
                break;
            }
        }
    }
    
    dist[x] = 0;
    pll ret = dfs2(x, 0);
    dfs3(x, 0, ret.first, ret.second);
    del[x] = 1;
    
    for (_edge i : edge[x]) {
        if (del[i.x]) continue;
        centroid(i.x);
    }
}

int par[200001];
int find(int x) {
    if (par[x]) return par[x] = find(par[x]);
    return x;
}

int merge(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return 0;
    par[x] = y;
    return 1;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> v[i];
	for (int i = 1; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        edge[a].emplace_back(b, c);
        edge[b].emplace_back(a, c);
	}
	
	centroid(1);
	sort(es.begin(), es.end());
	llong ans = 0;
	for (_es i : es) {
        if (merge(i.a, i.b)) ans += i.c;
	}
    printf("%lld\n", ans);
	return 0;
}
