#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, pos;
long long ans, MIN = 1e18;
int fa[N];
long long a[N];
struct edge {
  int u, v;
  long long w;
} e[N << 1];
inline bool cmp(const edge &a, const edge &b) { return a.w < b.w; }
inline int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline void together(int x, int y) {
  x = find(x), y = find(y);
  fa[x] = y;
}
inline void Kruskal(void) {
  for (register int i = 1; i <= n; ++i) fa[i] = i;
  for (register int i = 1; i <= m; ++i) {
    if (find(e[i].u) == find(e[i].v)) continue;
    together(e[i].u, e[i].v);
    ans += e[i].w;
  }
}
int main(void) {
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    if (a[i] < MIN) MIN = a[i], pos = i;
  }
  for (register int i = 1; i <= m; ++i)
    scanf("%d%d%lld", &e[i].u, &e[i].v, &e[i].w);
  for (register int i = 1; i <= n; ++i) e[++m] = (edge){pos, i, a[pos] + a[i]};
  sort(e + 1, e + m + 1, cmp);
  Kruskal();
  printf("%lld\n", ans);
  return 0;
}
