#include <bits/stdc++.h>
using namespace std;
struct _e {
  int x, y;
  long long w;
} edges[2 * 200010];
bool cmp(struct _e e1, struct _e e2) { return e1.w < e2.w; }
int link[200010], m, n, mn = 1;
long long p[200010];
int find(int x) { return x == link[x] ? x : link[x] = find(link[x]); }
long long kruskal(int s, int e) {
  sort(edges + s, edges + s + e, cmp);
  long long cost = 0;
  int c = 1;
  for (int i = 0; c < n; ++i) {
    int px = find(edges[i].x);
    int py = find(edges[i].y);
    if (px != py) link[py] = px, cost += edges[i].w, ++c;
  }
  return cost;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    if (p[mn] > p[i]) mn = i;
    link[i] = i;
  }
  for (int i = 1; i <= m; ++i) cin >> edges[i].x >> edges[i].y >> edges[i].w;
  for (int i = 1; i <= n; ++i)
    if (mn != i)
      edges[m + i].x = mn, edges[m + i].y = i, edges[m + i].w = p[mn] + p[i];
  cout << kruskal(1, m + n) << endl;
  return 0;
}
