/*
4
1 3 5 1
1 2 1
2 3 2
3 4 3
*/
#include <bits/stdc++.h>
using namespace std;
void print() { cout << '\n'; } template<class T, class ...U> void print(T x, U ...y) { cout << x << ' '; print(y...); }
typedef long long ll; const int N = 2e5 + 5, M = 1e9 + 7; typedef vector<int> vi; typedef vector<vi> vii; void Main();
int main(int argc, char **argv) {
  ios::sync_with_stdio(0), cin.tie(0); cout << setprecision(10) << fixed;
  #ifdef Zmm
  freopen((string(*(argv)).substr(2, string(*(argv)).size() - 6) + string(".cpp")).c_str(), "r", stdin); string x; cin >> x;
  #endif
  Main();
}
struct edge {
  int v, w;
};
vector<edge> G[N];
int x[N], siz[N], RT, RTMAX, vis[N], SIZE;
void getrt(int u, int fa) {
  int mx = 0;
  siz[u] = 1;
  for (edge &e : G[u]) if (e.v != fa && !vis[e.v]) {
    getrt(e.v, u);
    siz[u] += siz[e.v];
    mx = max(mx, siz[e.v]);
  }
  mx = max(mx, SIZE - siz[u]);
  if (mx < RTMAX) RTMAX = mx, RT = u;
}
int cnt, rtcnt;
ll diss[N], rtdis[N];
void getdis(int u, int fa, ll dis) {
  for (edge &e : G[u]) if (e.v != fa && !vis[e.v]) {
    diss[cnt++] = dis + e.w + x[e.v];
    getdis(e.v, u, diss[cnt - 1]);
  }
}

ll dfz(int u) {
  // cout << u << ' ' << vis[u] << '\n';
  rtcnt = 0;
  vis[u] = 1;
  ll ans = 0, sum = 0;
  rtdis[rtcnt++] = x[u];
  sum += x[u];
  for (edge &e : G[u]) if (!vis[e.v]) {
    // cout << u << ' ' << e.v << '\n';
    cnt = 0;
    diss[cnt++] = x[e.v] + e.w;
    getdis(e.v, u, e.w);
    sort(diss, diss + cnt);
    // print(u, e.v, diss[0]);
    // ans += diss[0];
    rtdis[rtcnt++] = diss[0];
    sum += diss[0];
    // print(u, diss[0], "..");
  }
  sort(rtdis, rtdis + rtcnt);
  ans += rtdis[0] * (rtcnt - 1) +(sum - rtdis[0]); 
  // print(u, ans);
  for (edge &e : G[u]) if (!vis[e.v]) {
    RT = RTMAX = SIZE = siz[e.v];
    getrt(e.v, u);
    ans += dfz(RT);
  }
  return ans;
}

void Main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1, u, v, w; i < n; i++) cin >> u >> v >> w, G[u].push_back({v, w}), G[v].push_back({u, w});
  RT = RTMAX = SIZE = n;
  getrt(1, 1);
  cout << dfz(RT) << '\n';
}