// ※※※ 解答不能 ※※※
// LHiC氏.
// https://atcoder.jp/contests/cf17-final/submissions/1806754
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second
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].a += dd[v];
        dd[v * 2 + 1] += dd[v];
        rmq[v * 2 + 2].a += 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] = {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].a += 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;
    repr(i, LOG - 1, 0) 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.a;
        if(u == p) continue;
        pp[u] = v;
        pc[u] = e.b;
        hh[u] = hh[v] + e.b;
        dfs1(u, v);
    }
    tout[v] = tm1;
}

void build(int v, int tl, int tr){
    if(tl + 1 == tr){
        rmq[v] = {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);
    rep(i, 4 * n) gg[i] = -1;
    rep(i, n) scanf("%lld", x + i);
    rep(i, n - 1){
        int a, b;
        LL c;
        scanf("%d%d%lld", &a, &b, &c);
        --a, --b;
        eds[a].push_back({b, c});
        eds[b].push_back({a, c});
    }
    int bst = 0;
    rep(i, n) if(x[i] < x[bst]) bst = i;
    pp[bst] = -1;
    dfs1(bst, -1);
    rep(i, n) up[0][i] = pp[i];
    up[0][bst] = bst;
    repx(i, 1, LOG) rep(j, n) up[i][j] = up[i - 1][up[i - 1][j]];
    rep(i, n) en[i] = 0;
    build(0, 0, n);
    sten(bst);
    rep(i, n) if(!en[i]) add(0, 0, n, tin[i], tin[i] + 1, x[i] + x[bst] + hh[i], bst);
    LL ans = 0;
    repx(i, 1, n){
        ans += rmq[0].a;
        int a = bc[rmq[0].b];
        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.a;
                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];
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 83072