#include <bits/stdc++.h>
using namespace std;
const int Max_n = 2e5 + 10;
const int Max_m = 4e5 + 10;
int f[Max_n];
struct A {
  long long val;
  int pos;
  bool operator<(const A &a) const { return val < a.val; }
} a[Max_n];
struct Edge {
  int u, v;
  long long cost;
  bool operator<(const Edge &edge) const { return cost < edge.cost; }
} edge[Max_m * 2];
int Find(int v) {
  if (f[v] == v) return v;
  return f[v] = Find(f[v]);
}
bool Merge(int m, int n) {
  int t1 = Find(m);
  int t2 = Find(n);
  if (t1 != t2) {
    f[t1] = t2;
    return true;
  }
  return false;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int cnt = 0;
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i].val);
    a[i].pos = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 2; i <= n; i++) {
    edge[cnt].u = a[1].pos;
    edge[cnt].v = a[i].pos;
    edge[cnt++].cost = a[1].val + a[i].val;
    edge[cnt].u = a[i].pos;
    edge[cnt].v = a[1].pos;
    edge[cnt++].cost = a[1].val + a[i].val;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long cost;
    scanf("%d%d%lld", &u, &v, &cost);
    edge[cnt].u = u;
    edge[cnt].v = v;
    edge[cnt++].cost = cost;
    edge[cnt].u = v;
    edge[cnt].v = u;
    edge[cnt++].cost = cost;
  }
  sort(edge, edge + cnt);
  long long ans = 0;
  int edgeCnt = 0;
  for (int i = 0; i < cnt; i++) {
    if (Merge(edge[i].u, edge[i].v)) {
      ans += edge[i].cost;
      edgeCnt++;
    }
    if (edgeCnt == n - 1) break;
  }
  printf("%lld\n", ans);
  return 0;
}
