#include <bits/stdc++.h>
using namespace std;
vector<int> p;
int get_head(int first) {
  return (first == p[first] ? first : p[first] = get_head(p[first]));
}
bool merge(int first, int second) {
  first = get_head(first);
  second = get_head(second);
  if (first == second) return false;
  p[first] = second;
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<pair<long long, pair<int, int>>> g(m);
  for (int i = 0; i < m; i++) {
    cin >> g[i].second.first >> g[i].second.second >> g[i].first;
    g[i].second.first--;
    g[i].second.second--;
  }
  int pos = 0;
  long long mn = a[0];
  for (int i = 1; i < n; i++)
    if (a[i] < mn) {
      mn = a[i];
      pos = i;
    }
  for (int i = 0; i < n; i++)
    if (i != pos) g.push_back({a[pos] + a[i], {pos, i}});
  sort(g.begin(), g.end());
  p.resize(n);
  for (int i = 0; i < n; i++) p[i] = i;
  long long ans = 0;
  for (int i = 0; i < (int)g.size(); i++)
    if (merge(g[i].second.first, g[i].second.second)) ans += g[i].first;
  cout << ans << endl;
  return 0;
}
