/**
 *    author:  tourist
 *    created: 25.11.2017 14:22:39       
**/
#include <bits/stdc++.h>

using namespace std;

class dsu {
  public:
  vector<int> p;
  int n;

  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

const long long inf = (long long) 1e18;

const int N = 200010;

vector< pair<int, int> > g[N];
int cost[N];
long long d[N][2];
int who[N][2];
int comp[N];
long long best[N];
int best_to[N];
int id[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", cost + i);
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    x--; y--;
    g[x].emplace_back(y, z);
    g[y].emplace_back(x, z);
  }
  int cnt = n;
  for (int i = 0; i < n; i++) {
    comp[i] = i;
  }
  long long ans = 0;
  while (cnt > 1) {
    set< pair<long long, int> > s;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 2; j++) {
        d[i][j] = inf;
        who[i][j] = -1;
      }
      d[i][0] = cost[i];
      who[i][0] = comp[i];
      s.emplace(d[i][0], 2 * i + 0);
    }
    while (!s.empty()) {
      int i = (*(s.begin())).second;
      s.erase(s.begin());
      int j = i & 1;
      i >>= 1;
      for (auto &p : g[i]) {
        int to = p.first;
        long long dt = d[i][j] + p.second;
        if (dt < d[to][0]) {
          if (who[i][j] != who[to][0]) {
            s.erase(make_pair(d[to][1], to * 2 + 1));
            d[to][1] = d[to][0];
            who[to][1] = who[to][0];
            s.emplace(d[to][1], to * 2 + 1);
          }
          s.erase(make_pair(d[to][0], to * 2 + 0));
          d[to][0] = dt;
          who[to][0] = who[i][j];
          s.emplace(d[to][0], to * 2 + 0);
        } else {
          if (who[i][j] != who[to][0] && dt < d[to][1]) {
            s.erase(make_pair(d[to][1], to * 2 + 1));
            d[to][1] = dt;
            who[to][1] = who[i][j];
            s.emplace(d[to][1], to * 2 + 1);
          }
        }
      }
    }

    for (int i = 0; i < cnt; i++) {
      best[i] = inf;
      best_to[i] = -1;
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 2; j++) {
        if (who[i][j] == comp[i]) {
          continue;
        }
        long long cur = d[i][j] + cost[i];
        if (cur < best[comp[i]]) {
          best[comp[i]] = cur;
          best_to[comp[i]] = who[i][j];
        }
      }
    }
    dsu dd(cnt);
    for (int i = 0; i < cnt; i++) {
      assert(best_to[i] != -1);
      if (best_to[i] == -2) {
        continue;
      }
      ans += best[i];
      dd.unite(i, best_to[i]);
      if (best_to[best_to[i]] == i) {
        best_to[best_to[i]] = -2;
      }
    }
    for (int i = 0; i < cnt; i++) {
      id[i] = -1;
    }
    for (int i = 0; i < n; i++) {
      comp[i] = dd.get(comp[i]);
      id[comp[i]] = 0;
    }
    int new_cnt = 0;
    for (int i = 0; i < cnt; i++) {
      if (id[i] != -1) {
        id[i] = new_cnt++;
      }
    }
    for (int i = 0; i < n; i++) {
      comp[i] = id[comp[i]];
    }
    cnt = new_cnt;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 47088