#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> arr(n);
  long long int sma_pt = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] < arr[sma_pt]) sma_pt = i;
  }
  vector<vector<long long int> > tree(n);
  map<pair<long long int, long long int>, long long int> weight;
  for (long long int i = 0; i < m; i++) {
    long long int x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    if (x > y) swap(x, y);
    if (arr[x] + arr[y] > w) {
      if (weight[make_pair(x, y)] == 0) {
        weight[make_pair(x, y)] = w;
      } else
        weight[make_pair(x, y)] = min(weight[make_pair(x, y)], w);
      tree[x].push_back(y);
      tree[y].push_back(x);
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (i != sma_pt) {
      tree[i].push_back(sma_pt);
      tree[sma_pt].push_back(i);
      long long int temp1 = i;
      long long int temp2 = sma_pt;
      if (temp1 > temp2) swap(temp1, temp2);
      if (weight[make_pair(temp1, temp2)] == 0)
        weight[make_pair(temp1, temp2)] = arr[temp1] + arr[temp2];
    }
  }
  vector<long long int> used(n);
  set<pair<long long int, long long int> > q;
  long long int ans = 0;
  q.insert(make_pair(0, 0));
  while (!q.empty()) {
    while (!q.empty() and used[q.begin()->second]) q.erase(q.begin());
    if (q.empty()) break;
    ans += q.begin()->first;
    used[q.begin()->second] = 1;
    long long int nd = q.begin()->second;
    for (long long int i = 0; i < (long long int)tree[nd].size(); i++) {
      long long int nxt = tree[nd][i];
      if (!used[nxt]) {
        if (nd > nxt)
          q.insert(make_pair(weight[make_pair(nxt, nd)], nxt));
        else
          q.insert(make_pair(weight[make_pair(nd, nxt)], nxt));
      }
    }
  }
  cout << ans;
}
