#include <bits/stdc++.h>
using namespace std;

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

vector<tuple<i64,i64,i64>> adjacent_cells(const vector<vector<pair<i64,i64>>> &graph,const vector<i64> us){
    using tup=tuple<i64,i64,i64>;

    const i64 size=graph.size();
    priority_queue<tup,vector<tup>,greater<tup>> que;
    vector<i64> from(size,-1),dist(size,inf64);
    vector<tup> es;

    for(auto u:us){
        que.push(make_tuple(0,u,u));
        dist[u]=0;
    }

    while(!que.empty()){
        auto t=que.top();
        que.pop();

        i64 d,u,f;
        tie(d,u,f)=t;

        if(from[u]!=-1) continue;
        from[u]=f;
        dist[u]=d;

        for(const auto &e:graph[u]){
            i64 v=e.first,c=e.second;
            if(from[v]!=-1){
                if(from[u]!=from[v]) es.emplace_back(make_tuple(dist[u]+dist[v]+c,from[u],from[v]));
            }else{
                if(dist[v]<=dist[u]+c) continue;
                dist[v]=dist[u]+c;
                que.push(make_tuple(dist[v],v,f));
            }
        }
    }

    return es;
}

class union_find {
private:
    vector<int> parent, rank, gs;
    int size;

public:
    int count_group;
    union_find() = default;
    union_find(int n) { init(n); }

    void init(int n) {
        size = n;
        count_group = n;
        parent.resize(size);
        rank.assign(size, 0);
        gs.assign(size, 1);
        for (int i = 0; i < size; ++i) parent[i] = i;
    }

    int find(int x) {
        if (parent[x] == x)
            return x;
        else
            return parent[x] = find(parent[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            parent[x] = y;
            gs[y] += gs[x];
        } else {
            parent[y] = x;
            gs[x] += gs[y];
            if (rank[x] == rank[y]) ++rank[x];
        }
        --count_group;
    }

    bool is_same_group(int x, int y) {
        return find(x) == find(y);
    }

    int group_size(int x) {
        return gs[find(x)];
    };
};

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;
    vector<i64> X(N);
    rep(i,0,N) cin >> X[i];
    vector<i64> A(N-1),B(N-1),C(N-1);
    rep(i,0,N-1){
        cin >> A[i] >> B[i] >> C[i];
        --A[i];
        --B[i];
    }

    using pii=pair<i64,i64>;
    vector<vector<pii>> graph(N+N);
    rep(i,0,N){
        graph[i].emplace_back(make_pair(i+N,X[i]));
        graph[i+N].emplace_back(make_pair(i,X[i]));
    }
    rep(i,0,N-1){
        i64 u=A[i]+N,v=B[i]+N;
        graph[u].emplace_back(make_pair(v,C[i]));
        graph[v].emplace_back(make_pair(u,C[i]));
    }

    vector<i64> us;
    rep(i,0,N) us.emplace_back(i);

    auto es=adjacent_cells(graph,us);

    sort(begin(es),end(es));

    union_find uf(N);
    i64 ans=0;
    for(auto e:es){
        i64 d,u,v;
        tie(d,u,v)=e;
        if(uf.is_same_group(u,v)) continue;
        uf.unite(u,v);
        ans+=d;
    }
    
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 72548