#include <bits/stdc++.h>
using namespace std;
vector<long long> child;
long long root(vector<long long>& tree, long long i) {
  if (i == tree[i]) {
    for (long long j = (0); j < (child.size()); j++) tree[child[j]] = i;
    child.clear();
    return i;
  } else {
    child.push_back(i);
    return i = root(tree, tree[i]);
  }
}
long long unit(vector<long long>& tree, long long x, long long y) {
  x = root(tree, x);
  y = root(tree, y);
  tree[max(x, y)] = min(x, y);
}
bool isUnit(vector<long long>& tree, long long x, long long y) {
  return root(tree, x) == root(tree, y);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  long long id;
  long long mn = 1LL << 60;
  for (long long i = (0); i < (n); i++) {
    cin >> a[i];
    if (mn > a[i]) {
      mn = a[i];
      id = i;
    }
  }
  vector<tuple<long long, long long, long long>> edge(m);
  for (long long i = (0); i < (m); i++) {
    long long a, b, w;
    cin >> a >> b >> w;
    edge[i] = make_tuple(w, a - 1, b - 1);
  }
  for (long long i = (0); i < (n); i++) {
    if (id == i) continue;
    edge.push_back(make_tuple(a[i] + a[id], i, id));
  }
  sort(edge.begin(), edge.end());
  vector<long long> tree(n);
  for (long long i = (0); i < (n); i++) tree[i] = i;
  long long ans = 0;
  for (long long i = (0); i < (n + m - 1); i++) {
    if (isUnit(tree, get<1>(edge[i]), get<2>(edge[i]))) continue;
    unit(tree, get<1>(edge[i]), get<2>(edge[i]));
    ans += get<0>(edge[i]);
  }
  cout << ans << endl;
  return 0;
}
