#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6;
long long int prnt[N] = {0}, sz[N] = {0};
long long int fin(long long int a) {
  if (prnt[a] == a) return a;
  return (prnt[a] = fin(prnt[a]));
}
void uni(long long int a, long long int b) {
  if (sz[a] <= sz[b]) {
    prnt[a] = b;
    sz[b]++;
  } else {
    prnt[b] = a;
    sz[a]++;
  }
}
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int arr[n];
  long long int mn = 1e13, idx;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] < mn) {
      mn = arr[i];
      idx = i;
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) prnt[i] = i;
  vector<pair<long long int, pair<long long int, long long int> > > vec;
  for (long long int i = 0; i < m; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    vec.push_back(make_pair(c, make_pair(a, b)));
  }
  for (long long int i = 0; i < n; i++) {
    if (i == idx) continue;
    vec.push_back(make_pair(mn + arr[i], make_pair(idx, i)));
  }
  sort(vec.begin(), vec.end());
  for (long long int i = 0; i < vec.size(); i++) {
    long long int a = vec[i].second.first, b = vec[i].second.second;
    long long int p = fin(a), q = fin(b);
    if (p == q) continue;
    uni(p, q);
    ans += vec[i].first;
  }
  cout << ans << endl;
}
