#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, pair<int, int>>> g;
long long int a[200005];
int par[200005];
vector<pair<long long int, int>> vec;
int parent(int u) {
  while (par[u] != u) u = par[u];
  return u;
}
void unin(int x, int y) {
  int u = parent(x);
  int v = parent(y);
  if (a[u] < a[v])
    par[v] = u;
  else
    par[u] = v;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int x, y;
  long long int w, ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> w;
    g.push_back({w, {x, y}});
  }
  for (int i = 0; i <= n; i++) par[i] = i;
  int z = min_element(a + 1, a + n + 1) - a;
  for (int i = 1; i <= n; i++) {
    if (i != z) g.push_back({a[i] + a[z], {i, z}});
  }
  sort(g.begin(), g.end());
  for (auto p : g) {
    x = p.second.first;
    y = p.second.second;
    int u = parent(x);
    int v = parent(y);
    if ((u != v)) {
      ans += p.first;
      unin(x, y);
    }
  }
  cout << ans << endl;
  return 0;
}
