#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
const long long Inf = 0x7f7f7f7f7f7f7f7f;
struct Node {
  long long x, y, w;
  bool operator<(const Node &a) const { return w < a.w; }
} node[MAXN];
long long tot, n, m, a[MAXN], pos, pos_num;
long long fa[MAXN];
long long find(long long x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = find(fa[x]);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  pos_num = Inf;
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < pos_num) pos_num = a[i], pos = i;
  }
  for (int i = 1; i <= n; i++) {
    if (i == pos) continue;
    node[++tot] = Node{pos, i, a[i] + a[pos]};
  }
  for (int i = 1; i <= m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    node[++tot] = Node{x, y, w};
  }
  sort(node + 1, node + tot + 1);
  long long cnt = 0, ans = 0;
  for (int i = 1; i <= tot; i++) {
    int x = find(node[i].x), y = find(node[i].y);
    if (x == y) continue;
    fa[x] = y;
    ans += node[i].w;
    cnt++;
    if (cnt == n - 1) break;
  }
  cout << ans;
  return 0;
}
