#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long nodes[N];
int root[N];
struct edge {
  int a, b;
  long long w;
  bool operator<(const edge& ne) const { return w > ne.w; }
};
priority_queue<edge> edges;
int find_root(int a) { return root[a] == a ? a : root[a] = find_root(root[a]); }
int main() {
  int n, m, index = 0;
  long long min = 0x3fffffffffffffff;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &nodes[i]);
    if (min >= nodes[i]) {
      min = nodes[i];
      index = i;
    }
  }
  edge temp;
  temp.a = index;
  for (int i = 1; i <= n; i++) {
    if (i == index) continue;
    temp.b = i;
    temp.w = nodes[index] + nodes[i];
    edges.push(temp);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%lld", &temp.a, &temp.b, &temp.w);
    edges.push(temp);
  }
  for (int i = 1; i <= n; i++) root[i] = i;
  long long ans = 0;
  while (!edges.empty()) {
    temp = edges.top();
    edges.pop();
    int a = find_root(temp.a), b = find_root(temp.b);
    if (a != b) {
      ans += temp.w;
      root[b] = a;
    }
  }
  printf("%lld\n", ans);
}
