#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
long long A[N], p[N];
vector<pair<long long, pair<long long, long long> > > adj;
long long getroot(long long x) {
  return (p[x] == x) ? x : p[x] = getroot(p[x]);
}
void mrg(long long u, long long v) {
  u = getroot(u), v = getroot(v);
  p[u] = v;
  return;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, mn = 0;
  cin >> n >> m;
  A[0] = 1e17;
  for (int i = 1; i <= n; i++) {
    p[i] = i;
    cin >> A[i];
    if (A[i] < A[mn]) mn = i;
  }
  for (int i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    adj.push_back({w, {u, v}});
  }
  for (int i = 1; i <= n; i++) {
    if (i == mn) continue;
    adj.push_back({A[i] + A[mn], {i, mn}});
  }
  sort(adj.begin(), adj.end());
  long long ans = 0;
  for (auto u : adj) {
    if (getroot(u.second.first) != getroot(u.second.second)) {
      mrg(u.second.first, u.second.second);
      ans += u.first;
    }
  }
  cout << ans;
}
