#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, int> > V;
vector<vector<pair<long long, int> > > edges;
long long MST(const vector<vector<pair<long long, int> > >& edges) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      Q;
  vector<int> seen((int)edges.size(), 0);
  int root = edges[0].empty() ? 1 : 0;
  seen[root] = 1;
  int counter = 1;
  int prv = root;
  long long cost = 0;
  for (auto& e : edges[root]) Q.push(e);
  while (!Q.empty()) {
    auto curr = Q.top();
    Q.pop();
    if (seen[curr.second]) continue;
    for (auto& e : edges[curr.second]) Q.push(e);
    seen[curr.second] = 1;
    cost += curr.first;
    prv = curr.second;
    counter++;
  }
  return cost;
}
int main() {
  int n, m, x, y;
  long long w;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &w);
    V.push_back(pair<long long, int>(w, i));
  }
  sort(V.begin(), V.end());
  edges.assign(n + 5, vector<pair<long long, int> >());
  for (int j = 1; j < n; j++) {
    edges[V[0].second].push_back(
        pair<long long, int>(V[0].first + V[j].first, V[j].second));
    edges[V[j].second].push_back(
        pair<long long, int>(V[0].first + V[j].first, V[0].second));
  }
  while (m--) {
    scanf("%d %d %I64d", &x, &y, &w);
    edges[x].push_back(pair<long long, int>(w, y));
    edges[y].push_back(pair<long long, int>(w, x));
  }
  printf("%I64d\n", MST(edges));
  return 0;
}
