#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, pair<long long int, long long int> > > vv;
long long int ara[200005], parent[200005];
long long int Find(long long int r) {
  if (parent[r] == r) return r;
  return parent[r] = Find(parent[r]);
}
int main() {
  long long int n, m, i, j, mn = 1e18, mn_indx = -1;
  scanf("%I64d %I64d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &ara[i]);
    if (ara[i] < mn) {
      mn = ara[i];
      mn_indx = i;
    }
  }
  for (i = 1; i <= m; i++) {
    long long int u, v, w;
    scanf("%I64d %I64d %I64d", &u, &v, &w);
    if (w <= (ara[u] + ara[v])) vv.push_back({w, {u, v}});
  }
  for (i = 1; i <= n; i++) {
    if (mn_indx == i) continue;
    vv.push_back({ara[mn_indx] + ara[i], {i, mn_indx}});
  }
  sort(vv.begin(), vv.end());
  for (i = 1; i <= n; i++) {
    parent[i] = i;
  }
  long long int ans = 0, cnt = 0;
  for (i = 0; i < vv.size(); i++) {
    long long int u = Find(vv[i].second.first), v = Find(vv[i].second.second);
    if (u != v) {
      parent[v] = u;
      cnt++;
      ans += vv[i].first;
      if (cnt == n - 1) {
        break;
      }
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
