#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
long long MOD = 1000000009;
struct dsu {
  int n;
  vector<int> par;
  vector<int> s;
  int conn;
  dsu() {}
  dsu(int _n) {
    n = _n;
    conn = _n;
    par.resize(n + 1);
    s.resize(n + 1);
    for (int i = 1; i <= n; i++) {
      par[i] = i;
      s[i] = 1;
    }
  }
  int find(int x) {
    while (x != par[x]) {
      par[x] = par[par[x]];
      x = par[x];
    }
    return x;
  }
  void merge(int x, int y) {
    int p1 = find(x);
    int p2 = find(y);
    if (p1 != p2) {
      if (s[p1] >= s[p2]) {
        s[p1] += s[p2];
        par[p2] = p1;
      } else {
        s[p2] += s[p1];
        par[p1] = p2;
      }
      conn -= 1;
    }
  }
  void reset() {
    conn = n;
    for (int i = 1; i <= n; i++) {
      par[i] = i;
      s[i] = 1;
    }
  }
  int conn_comp() { return conn; }
  void print() {
    for (int i = 1; i <= n; i++) cout << i << "  -->" << par[i] << '\n';
  }
};
void solve() {
  int n, m;
  cin >> n >> m;
  dsu uf(n);
  pair<long long int, int> a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  vector<pair<long long int, pair<int, int>>> edgel;
  for (int i = 0; i < m; i++) {
    int x, y;
    long long int w;
    cin >> x >> y >> w;
    edgel.push_back({min(w, a[x].first + a[y].first), {x, y}});
  }
  int pos = min_element(a + 1, a + n + 1) - a;
  for (int i = 1; i <= n; i++) {
    if (i != pos) edgel.push_back({a[i].first + a[pos].first, {pos, i}});
  }
  sort((edgel).begin(), (edgel).end());
  long long int mst_cost = 0;
  for (auto v : edgel) {
    int x = v.second.first;
    int y = v.second.second;
    if (uf.find(x) != uf.find(y)) {
      mst_cost += v.first;
      uf.merge(x, y);
    }
  }
  cout << mst_cost << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
