#include <bits/stdc++.h>
using namespace std;
const int N = 200043;
int p[N];
long long a[N];
int get_leader(int first) {
  return (first == p[first] ? first : (p[first] = get_leader(p[first])));
}
bool merge(int first, int second) {
  first = get_leader(first);
  second = get_leader(second);
  if (first == second) return false;
  p[first] = second;
  return true;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  vector<pair<long long, pair<int, int> > > es(m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %lld", &es[i].second.first, &es[i].second.second,
          &es[i].first);
    es[i].second.first--;
    es[i].second.second--;
  }
  int z = min_element(a, a + n) - a;
  for (int i = 0; i < n; i++)
    if (i != z) es.push_back(make_pair(a[i] + a[z], make_pair(i, z)));
  sort(es.begin(), es.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) p[i] = i;
  for (auto e : es)
    if (merge(e.second.first, e.second.second)) ans += e.first;
  printf("%lld\n", ans);
  return 0;
}
