#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 60)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

struct edge {
    int to;
    ll cost;
};

struct info {
    int cl1;
    ll dist1;
    int cl2;
    ll dist2;
};

vector<edge> G[MAX_N];
ll x[MAX_N];
vector<int> g[MAX_N];
int cl[MAX_N];
pll mn[MAX_N];
info dp1[MAX_N], dp2[MAX_N];

void update(info& a, info& b)
{
    if(a.dist1 > b.dist1){
        if(a.cl1 != b.cl1){
            a.cl2 = a.cl1, a.dist2 = a.dist1;
        }
        a.cl1 = b.cl1, a.dist1 = b.dist1;
        if(a.cl1 != b.cl2 && a.dist2 > b.dist2){
            a.cl2 = b.cl2, a.dist2 = b.dist2;
        }
    }else{
        if(a.cl1 != b.cl1 && a.dist2 > b.dist1){
            a.cl2 = b.cl1, a.dist2 = b.dist1;
        }else{
            if(a.cl1 != b.cl2 && a.dist2 > b.dist2){
                a.cl2 = b.cl2, a.dist2 = b.dist2;
            }
        }
    }
}

void dfs(int u, int p)
{
    dp1[u] = (info){MOD, INF, MOD, INF};
    each(e,G[u]){
        if(e.to != p){
            info hoge = {cl[e.to], x[e.to]+e.cost, MOD, INF};
            update(dp1[u], hoge);
            dfs(e.to, u);
            hoge = dp1[e.to];
            hoge.dist1 += e.cost, hoge.dist2 += e.cost;
            update(dp1[u], hoge);
        }
    }
}

void redfs(int u, int p)
{
    if(u){
        update(dp2[u], dp1[u]);
    }else{
        dp2[u] = dp1[u];
    }
    each(e,G[u]){
        if(e.to != p){
            info hoge = dp2[u];
            hoge.dist1 += e.cost, hoge.dist2 += e.cost;
            dp2[e.to] = hoge;
            hoge = {cl[u], x[u]+e.cost, MOD, INF};
            update(dp2[e.to], hoge);
            redfs(e.to, u);
        }
    }
    if(cl[u] != dp2[u].cl1){
        if(mn[cl[u]].fi > dp2[u].dist1 + x[u]){
            mn[cl[u]] = pll(dp2[u].dist1 + x[u], dp2[u].cl1);
        }
    }else{
        if(mn[cl[u]].fi > dp2[u].dist2 + x[u]){
            mn[cl[u]] = pll(dp2[u].dist2 + x[u], dp2[u].cl2);
        }
    }
}

class UF {
private:
    int sz;
public:
    vector<int> kind;   //所属しているグループ番号
    vector<vector<int> > inc;   //グループのメンバー
    UF(){}
    UF(int node_size){ sz = node_size; kind.resize(sz),inc.resize(sz); rep(i,sz){ kind[i] = i; inc[i].pb(i); } }
    bool same(int a,int b){ return kind[a] == kind[b]; }
    void unite(int a,int b)
    { if(same(a,b)) return; if(inc[kind[a]].size() < inc[kind[b]].size()) swap(a,b);
        int ga = kind[a],gb = kind[b]; rep(i,inc[gb].size()) kind[inc[gb][i]] = ga;
        inc[ga].insert(inc[ga].end(),inc[gb].begin(),inc[gb].end()); inc[gb].clear(); }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        cin >> x[i];
    }
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        G[a-1].pb((edge){b-1,c}), G[b-1].pb((edge){a-1,c});
    }
    rep(i,n){
        cl[i] = i;
        g[i].pb(i);
    }
    int rem = n;
    ll ans = 0;
    while(rem > 1){
        rep(i,n){
            mn[i] = pll(INF, INF);
        }
        dfs(0, -1);
        redfs(0, -1);
        set<P> st;
        UF uf(n);
        rep(i,n){
            if(mn[i].fi < INF){
                if(!uf.same(i, mn[i].se)){
                    uf.unite(i, mn[i].se);
                    ans += mn[i].fi;
                    rem--;
                }
            }
        }
        rep(i,n){
            int nw = 0, nx = 1;
            while(nx < (int)uf.inc[i].size()){
                if((int)g[uf.inc[i][nw]].size() < (int)g[uf.inc[i][nx]].size()){
                    each(v, g[uf.inc[i][nw]]){
                        g[uf.inc[i][nx]].pb(v);
                        cl[v] = uf.inc[i][nx];
                    }
                    nw = nx;
                    nx++;
                }else{
                    each(v, g[uf.inc[i][nx]]){
                        g[uf.inc[i][nw]].pb(v);
                        cl[v] = uf.inc[i][nw];
                    }
                    nx++;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 82592