#include <bits/stdc++.h>
using namespace std;
const char duom[] = "i.txt";
long long value[200005];
long long father[200005];
vector<pair<long long, pair<long long, long long>>> edgy;
long long ans;
int findFather(int x) {
  if (x == father[x]) return x;
  return father[x] = findFather(father[x]);
}
bool tikrinam(int x, int y) {
  x = findFather(x);
  y = findFather(y);
  if (x == y) return false;
  father[x] = y;
  return true;
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long maziukas = 1e13;
  long long maziukas_ind;
  for (int i = 1; i <= n; i++) {
    cin >> value[i];
    father[i] = i;
    if (maziukas > value[i]) {
      maziukas = value[i];
      maziukas_ind = i;
    }
  }
  for (int i = 1; i <= n; i++)
    if (i != maziukas_ind) {
      edgy.push_back(make_pair(value[maziukas_ind] + value[i],
                               make_pair(maziukas_ind, i)));
    }
  for (int i = 1; i <= m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    edgy.push_back(make_pair(w, make_pair(x, y)));
  }
  sort(edgy.begin(), edgy.end());
  for (auto i : edgy) {
    if (tikrinam(i.second.first, i.second.second)) {
      ans += i.first;
    }
  }
  cout << ans;
  return 0;
}
