#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 10;
struct node {
  int fr;
  int to;
  long long cost;
} q[maxn];
long long a[maxn];
int father[maxn], num;
int Find(int t) { return t == father[t] ? t : father[t] = Find(father[t]); }
bool cmp(node t1, node t2) { return t1.cost < t2.cost; }
long long krustra() {
  long long sum = 0;
  for (int i = 1; i <= num; i++) {
    int t1 = Find(q[i].fr);
    int t2 = Find(q[i].to);
    if (t1 != t2) {
      father[t1] = t2;
      sum += q[i].cost;
    }
  }
  return sum;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  long long minn = 1ll << 60;
  int id = 0;
  for (int i = 1; i <= n; i++) {
    father[i] = i;
    scanf("%lld", &a[i]);
    if (a[i] < minn) {
      minn = a[i];
      id = i;
    }
  }
  int st, ed;
  long long co;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %lld", &st, &ed, &co);
    co = min(a[st] + a[ed], co);
    q[++num].fr = st;
    q[num].to = ed;
    q[num].cost = co;
  }
  for (int i = 1; i <= n; i++) {
    if (i == id) continue;
    q[++num].fr = i;
    q[num].to = id;
    q[num].cost = a[i] + a[id];
  }
  sort(q + 1, q + num + 1, cmp);
  long long ans = krustra();
  printf("%lld\n", ans);
  return 0;
}
