#include <bits/stdc++.h>
using namespace std;
struct DSF {
  DSF* parent = this;
  DSF* find() {
    if (parent != this) parent = parent->find();
    return parent;
  }
  void join(DSF& second) {
    auto root1 = find();
    auto root2 = second.find();
    root1->parent = root2;
  }
};
int main(int argc, char* argv[]) {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  int n, m;
  cin >> n >> m;
  auto w = vector<long long>(n);
  for (int i = 0; i < (n); ++i) cin >> w[i];
  vector<pair<long long, pair<int, int>>> edges;
  for (int i = 0; i < (m); ++i) {
    int a, b;
    long long x;
    cin >> a >> b >> x;
    edges.push_back({x, {--a, --b}});
  }
  int v_min = 0;
  long long w_min = w[0];
  for (int i = 0; i < (n); ++i)
    if (w[i] < w_min) {
      w_min = w[i];
      v_min = i;
    }
  for (int i = 0; i < (n); ++i)
    if (i != v_min) edges.push_back({w[i] + w[v_min], {i, v_min}});
  sort((edges).begin(), (edges).end());
  auto ans = 0ll;
  auto dsf = vector<DSF>(n);
  for (auto& each : edges) {
    if (dsf[each.second.first].find() != dsf[each.second.second].find()) {
      ans += each.first;
      dsf[each.second.first].join(dsf[each.second.second]);
    }
  }
  cout << ans << '\n';
  return 0;
}
