#include <bits/stdc++.h>
using namespace std;
int n, m, fa[200010], cnt, deals[200010];
long long v[200010], ans, minn = 1000000000010, mid;
struct edge {
  int u, v;
  long long w;
} q[500010];
bool cmp(edge a, edge b) { return a.w < b.w; }
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &v[i]);
    fa[i] = i;
    if (v[i] < minn) {
      minn = v[i];
      mid = i;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (i == mid) continue;
    q[i].u = mid;
    q[i].v = i;
    q[i].w = v[mid] + v[i];
  }
  for (int i = n + 1; i <= n + m; ++i) {
    scanf("%d%d%lld", &q[i].u, &q[i].v, &q[i].w);
  }
  sort(q + 1, q + 1 + n + m, cmp);
  for (int i = 1; i <= n + m; ++i) {
    int x = find(q[i].u), y = find(q[i].v);
    if (x != y) {
      fa[y] = x;
      ans += q[i].w;
    }
  }
  printf("%lld", ans);
  return 0;
}
