#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;

#define nmax 200500

typedef long long ll;
//#define int ll

int n;
set<pair<int, ll> > g[2*nmax];
set<pair<int, ll> > gs[nmax];
vector<pair<int, ll> > gv[2*nmax];
int cur[nmax];
queue<int> listiki;
ll x[nmax];
ll xs[nmax];

vector<int> procrastinate;

//set<pair<ll, int> > st;
ll d[2*nmax];

const int C = 500;
//200000 / 1500 = 100

//void ch(int pos, ll val)
//{
//    st.erase({d[pos], pos});
//    d[pos]=val;
//    st.insert({d[pos], pos});
//}

/*
6
44000000000 23000000000 31000000000 29000000000 32000000000 15000000000
1 2 10000000000
1 3 12000000000
1 4 16000000000
4 5 8000000000
4 6 15000000000
*/
bool alr[nmax];
int state [2*nmax];
deque<int> q;

void dijkstra(bool first = false)
{
//    st.clear();
//    for (int i=1; i<=n; i++)
//        ch(i, 1e18);
//
////    for (int i=1; i<=n; i++)
////        g[i]=gs[i];
////    for (int i=n+1; i<=2*n; i++)
////        g[i].clear();
//
//    for (int i=1; i<=n; i++)
//        if (alr[i])
//            ch(n+i, 0);
//
//    while (!st.empty())
//    {
//        auto v = st.begin()->se;
//        if (d[v]==1e18)
//            break;
//        st.erase(st.begin());
//
//        for (auto pax: gv[v])
//        {
//            if (d[pax.fi] > d[v] + pax.se)
//                ch(pax.fi, d[v]+pax.se);
//        }
//    }
    if (first)
    {
        for (int i=1; i<=2*n; i++)
            d[i]=1e18;
        d[0]=0;
    }

    for (int i=1; i<=2*n; i++)
        state[i]=2;
    state[0] = 1;

    q.clear();
    q.push_back (0);

    while (!q.empty())
    {
        int vertex = q.front();
        q.pop_front();
        state[vertex] = 0;
        for (size_t i = 0; i < gv[vertex].size(); ++i)
        {
            int to = gv[vertex][i].first;
              ll length = gv[vertex][i].second;
            if (d[to] > d[vertex] + length)
            {
                d[to] = d[vertex] + length;
                if (state[to] == 2)
                    q.push_back (to);
                else if (state[to] == 0)
                    q.push_front (to);
                state[to] = 1;
            }
        }
    }
}

ll dist_to_root[nmax];
int dep[nmax];

void dfs(int v, int p=-1, ll d=0, int depth=0)
{
    dist_to_root[v]=d;
    dep[v]=depth;
//    lca[v][0]=p;
    for (auto pa:gs[v])
        if (pa.fi != p)
            dfs(pa.fi, v, d+pa.se, depth+1);
}
int lcaf(int u, int v);
//{
//    if (dep[u] < dep[v])
//        swap(u, v);
//    if (dep[u] > dep[v])
//    {
//        for (int i = 19; i>=0; i--)
//            if (lca[u][i]!=-1)
//                if (dep[lca[u][i]] >= dep[v])
//                    u=lca[u][i];
//    }
//    if (u==v)
//        return u;
//    for (int i=19; i>=0; i--)
//        if (lca[u][i]!=-1)
//            if (lca[u][i] != lca[v][i])
//                    u=lca[u][i], v=lca[v][i];
//    return lca[u][0];
//}
ll dist(int u, int v)
{
    return dist_to_root[u] + dist_to_root[v] - 2*dist_to_root[lcaf(u, v)];
}

vector<pair<signed, signed> > eul;
int tin[nmax];
#define log2 notlog2
int log2[2*nmax];
void dfs2(int v, int p=-1, int d=0)
{
    tin[v]=eul.size();
    eul.pb({d, v});
    for (auto pa:gs[v])
        if (pa.fi != p)
        {
            dfs2(pa.fi, v, d+1);
            eul.pb({d, v});
        }
}

pair<signed, signed> sparse[2*nmax][20];
void build()
{
    log2[1]=0;
    for (size_t i=2; i<=eul.size(); i++)
        log2[i]=log2[i/2]+1;

    for (size_t i=0; i<eul.size(); i++)
        sparse[i][0]=eul[i];
    for (int j=1; j<20; j++)
        for (size_t i=0; i+(1<<j)-1<eul.size(); i++)
    {
        sparse[i][j]=min(sparse[i][j-1], sparse[i+(1<<(j-1))][j-1]);
    }
}
pair<int, int> get(int l, int r)
{
    if (l>r)
        swap(l, r);
    int j=log2[r-l+1];
    return min(sparse[l][j], sparse[r-(1<<j)+1][j]);
}
int lcaf(int u, int v){

    int x=get(tin[u], tin[v]).second;
//    cout<<u<<" "<<v<<" "<<x<<"\n";
    return x;
}

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for (int i=1; i<=n; i++)
        cin>>x[i], xs[i]=x[i];

//    n=1e5;
//    for (int i=1; i<=n; i++)
//        x[i]=rand()+100;

    for (int i=1; i<=n; i++)
        cur[i]=i;
    for (int i=1; i<n; i++)
    {
        int x, y;
        ll w;
        cin>>x>>y>>w;
//        x=i;
//        y=i+1;
//        w=rand()+100;

        g[x].insert({y, w});
        g[y].insert({x, w});
        gs[x].insert({y, w});
        gs[y].insert({x, w});
        gv[x].pb({y, w});
        gv[y].pb({x, w});
    }
    for (int i=1; i<=n; i++)
        if (g[i].size()==1)
            listiki.push(i);
    for (int _=1; _<n; _++)
    {
        int s=listiki.front();
        listiki.pop();

        int t=g[s].begin()->fi;
        ll w=g[s].begin()->se;
//        cout<<t<<" "<<w<<endl;

        if (x[t] <= x[s] + w)
        {
            procrastinate.push_back(cur[s]);
        }
        else
        {
            procrastinate.push_back(cur[t]);
            cur[t]=cur[s];
            x[t] = x[s] + w;
        }
        g[t].erase({s, w});
        if (g[t].size()==1)
            listiki.push(t);
    }
    for (int i=1; i<=n; i++)
        x[i]=xs[i];
    alr[cur[listiki.front()]]=1;

    reverse(procrastinate.begin(), procrastinate.end());
//    for (int i:procrastinate)
//        cout<<i<<" ";
//    cout<<endl;

    dfs(1);
    dfs2(1);
    build();

//    for (int i=1; i<20; i++)
//    {
//        for (int j=1; j<=n; j++)
//        {
//            if (lca[j][i-1]!=-1)
//                lca[j][i] = lca[ lca[j][i-1] ][i-1];
//            else
//                lca[j][i] = -1;
//        }
//    }

    ll ans=0;

//    for (int i=1; i<=n; i++)
//        if (procrastinate.find(i) != procrastinate.end())
//            ans+=d[n+i];

//    for (int i=1; i<=n; i++)
//        for (int j=i+1; j<=n; j++)
//            cout<<i<<" "<<j<<" "<<dist(i, j)<<"\n";

    int counter=0;
    set<int> buffer = {cur[listiki.front()]};

    for (int i:procrastinate)
    {
        if ((counter++)%C == 0)
        {
            for (int i:buffer)
            {
                //gv[i].pb({n+i, x[i]});
                gv[n+i].pb({i, x[i]});
                gv[0].pb({n+i, 0});
            }
            dijkstra(counter == 1);
            buffer.clear();
        }

        ll mindist=d[i];

        for (int j: buffer)
        {
            mindist=min(mindist, dist(i, j)+xs[j]);
        }

//        cout<<i<<" "<<mindist<<" "<<d[i]<<"\n";

        ans += mindist + xs[i];

        alr[i]=1;
        buffer.insert(i);
    }

    cout<<ans<<"\n";
}


Measured memory_bytes: 203776