#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const long long INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const long long MOD = 1e9;
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
struct Edge {
  int fr;
  int to;
  long long dis;
  Edge() = default;
  Edge(int fr, int to, long long dis) : fr(fr), to(to), dis(dis) {}
  bool operator<(const Edge& b) const { return this->dis < b.dis; }
};
int n, m, k;
int CASE;
const int MAXN = 200005;
vector<Edge> edges;
long long val[MAXN];
int parent[MAXN];
int find(int p) {
  while (p != parent[p]) {
    parent[p] = parent[parent[p]];
    p = parent[p];
  }
  return p;
}
int main() {
  scanf("%d %d", &n, &m);
  long long minn = 1e18;
  int minni = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &val[i]);
    if (val[i] < minn) {
      minn = val[i];
      minni = i;
    }
    parent[i] = i;
  }
  int u, v;
  long long w;
  for (int i = 0; i < m; i++) {
    scanf("%d %d %lld", &u, &v, &w);
    edges.push_back({u, v, w});
  }
  for (int i = 1; i <= n; i++) {
    if (i != minni) {
      edges.push_back({minni, i, val[minni] + val[i]});
    }
  }
  sort(edges.begin(), edges.end());
  long long ans = 0;
  for (auto e : edges) {
    int x = find(e.fr), y = find(e.to);
    if (x != y) {
      parent[x] = y;
      ans += e.dis;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
