#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, parent[200002];
long long data[200002], c;
vector<pair<long long, pair<int, int> > > edge;
int root(int x) {
  if (parent[x] == x)
    return x;
  else
    return parent[x] = root(parent[x]);
}
bool gabung(int x, int y) {
  int rx = root(x);
  int ry = root(y);
  if (rx == ry) return false;
  parent[rx] = ry;
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  int idx = 1;
  for (int i = 1; i <= n; i++) {
    cin >> data[i];
    if (data[i] < data[idx]) idx = i;
  }
  for (int i = 1; i <= n; i++) {
    if (idx != i)
      edge.push_back(make_pair(data[i] + data[idx], make_pair(idx, i)));
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    edge.push_back(make_pair(c, make_pair(a, b)));
  }
  for (int i = 1; i <= n; i++) parent[i] = i;
  sort(edge.begin(), edge.end());
  long long sum = 0;
  for (int i = 0; i < edge.size(); i++) {
    int u = edge[i].second.first;
    int v = edge[i].second.second;
    long long cost = edge[i].first;
    if (gabung(u, v)) sum += cost;
  }
  cout << sum << endl;
}
