#include <bits/stdc++.h>
using namespace std;
const int N = 202020;
int n, m;
int p[N];
long long a[N];
long long res;
vector<pair<long long, pair<int, int> > > es;
int get_leader(int x) { return (x == p[x] ? x : (p[x] = get_leader(p[x]))); }
bool merge(int x, int y) {
  x = get_leader(x);
  y = get_leader(y);
  if (x == y) {
    return false;
  }
  p[x] = y;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  es.resize(m);
  for (int i = 0; i < m; i++) {
    cin >> 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({a[i] + a[z], {i, z}});
    }
  }
  sort(es.begin(), es.end());
  for (int i = 0; i < n; i++) {
    p[i] = i;
  }
  for (auto e : es) {
    if (merge(e.second.first, e.second.second)) {
      res += e.first;
    }
  }
  cout << res << '\n';
  return 0;
}
