#include <bits/stdc++.h>
using namespace std;
int n, m, par[200005];
long long arr[200005];
vector<pair<long long, pair<int, int>>> v;
int find(int x) {
  if (par[x] == x) return x;
  return par[x] = find(par[x]);
}
int uni(int a, int b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    par[b] = a;
    return 1;
  }
  return 0;
}
int main() {
  long long vk = 1000000000006;
  int k = 1;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (vk > arr[i]) {
      vk = arr[i];
      k = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i != k) {
      v.push_back(make_pair(arr[i] + arr[k], make_pair(i, k)));
    }
  }
  int a, b;
  long long c;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    v.push_back(make_pair(c, make_pair(a, b)));
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (auto it : v) {
    if (uni(it.second.first, it.second.second) == 1) ans += it.first;
  }
  cout << ans << "\n";
  return 0;
}
