#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int n, m;
long long a[N];
vector<pair<long long, pair<int, int> > > c;
int lab[N];
long long mn = 1e18, res;
int x;
int root(int x) { return lab[x] < 0 ? x : lab[x] = root(lab[x]); }
void union1(int s, int r) {
  if (lab[s] < lab[r]) swap(s, r);
  lab[r] += lab[s];
  lab[s] = r;
}
void dsu() {
  sort(c.begin(), c.end());
  memset(lab, -1, sizeof(lab));
  for (int i = 0; i < int(c.size()); i++) {
    int u = c[i].second.first, v = c[i].second.second;
    long long w = c[i].first;
    int s = root(u), r = root(v);
    if (s != r) {
      union1(s, r);
      res += w;
      n--;
    }
    if (n == 1) break;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < mn) {
      x = i;
      mn = a[i];
    }
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long w;
    cin >> u >> v >> w;
    if (w < a[u] + a[v])
      c.push_back(pair<long long, pair<int, int> >(w, pair<int, int>(u, v)));
  }
  for (int i = 1; i <= n; i++)
    if (i != x)
      c.push_back(
          pair<long long, pair<int, int> >(mn + a[i], pair<int, int>(x, i)));
  dsu();
  cout << res;
}
