#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long x, y, w;
} e[200010 * 2];
long long n, m;
long long a[200010], fa[200010];
long long findset(long long x) {
  return (x == fa[x]) ? x : (fa[x] = findset(fa[x]));
}
bool cmp(edge x, edge y) { return x.w < y.w; }
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = (1); i <= (n); ++i) fa[i] = i;
  for (int i = (1); i <= (n); ++i) scanf("%lld", &a[i]);
  for (int i = (1); i <= (m); ++i) {
    long long x, y, w;
    scanf("%lld%lld%lld", &x, &y, &w);
    e[i] = {x, y, w};
  }
  long long minw = 1e14, minpos = 0;
  for (int i = (1); i <= (n); ++i)
    if (a[i] < minw) {
      minw = a[i];
      minpos = i;
    }
  for (int i = (1); i <= (n); ++i)
    if (i != minpos) {
      e[++m] = {minpos, i, a[i] + a[minpos]};
    }
  sort(e + 1, e + m + 1, cmp);
  long long ans = 0;
  for (int i = (1); i <= (m); ++i) {
    long long x = e[i].x, y = e[i].y, w = e[i].w;
    long long fax = findset(x), fay = findset(y);
    if (fax != fay) {
      ans += w;
      fa[fay] = fax;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
