#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void scan(T &__ret) {
  __ret = T();
  char c = 0;
  bool neg = 0;
  while (isdigit(c) == 0 && c != '-') c = getchar();
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; isdigit(c) != 0; c = getchar()) __ret = __ret * 10 + c - '0';
  __ret = (neg) ? -__ret : __ret;
}
template <class T>
void print(T __X) {
  if (__X < 0) {
    putchar('-');
    __X *= -1;
  }
  if (__X > 9) print(__X / 10);
  putchar(__X % 10 + '0');
}
struct Tomorrowland {
  vector<int> lab;
  int n;
  int find(int u) { return (lab[u] < 0) ? u : (lab[u] = find(lab[u])); }
  bool unite(int u, int v) {
    int r = find(u);
    int s = find(v);
    if (r != s) {
      if (lab[s] < lab[r]) swap(r, s);
      lab[r] += lab[s];
      lab[s] = r;
      return 1;
    }
    return 0;
  }
  Tomorrowland() {}
  Tomorrowland(int __n) {
    n = __n;
    lab = vector<int>(n + 1, -1);
  }
};
struct edge {
  int u, v;
  long long w;
  edge(int u, int v, long long pp) : u(u), v(v), w(pp) {}
  edge() {}
  bool operator<(const edge &oth) const { return w < oth.w; }
};
vector<edge> edgList;
int n, m;
vector<vector<int>> adj;
vector<pair<long long, int>> a;
void FileInit() {
  {
    freopen(
        ""
        ".inp",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
}
void FileDebug() {
  {
    freopen(
        ""
        ".inp",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
}
void FileClose() {
  fclose(stdin);
  fclose(stdout);
}
void Enter() {
  int u, v;
  long long c;
  cin >> n >> m;
  a = vector<pair<long long, int>>(n + 1);
  for (auto i = 1; i <= n; ++i) {
    scan(c);
    a[i] = pair<long long, int>(c, i);
  }
  for (auto i = 1; i <= m; ++i) {
    scan(u);
    scan(v);
    scan(c);
    edgList.push_back(edge(u, v, c));
  }
}
void Edgeee() {
  long long c;
  int kar98K = n * 4;
  int x, y;
  priority_queue<tuple<long long, int, int>, vector<tuple<long long, int, int>>,
                 greater<tuple<long long, int, int>>>
      pq;
  for (auto i = 2; i <= n; ++i)
    pq.push(tuple<long long, int, int>(a[i].first + a[1].first, 1, i));
  while (kar98K--) {
    tuple<long long, int, int> p = pq.top();
    pq.pop();
    tie(c, x, y) = p;
    if (x >= y) continue;
    pq.push(tuple<long long, int, int>(a[x + 1].first + a[y].first, x + 1, y));
    edgList.push_back(edge(a[x].second, a[y].second, c));
    if (x == n - 1) break;
  }
  while (!pq.empty()) {
    tie(c, x, y) = pq.top();
    pq.pop();
    if (x != y) edgList.push_back(edge(a[x].second, a[y].second, c));
  }
}
void Solve() {
  if (n == 1) {
    puts("0");
    return;
  }
  Tomorrowland ctb(n);
  sort(a.begin() + 1, a.end());
  long long res = 0LL;
  Edgeee();
  sort(edgList.begin(), edgList.end());
  for (edge e : edgList) {
    if (ctb.unite(e.u, e.v)) {
      res += e.w;
    }
  }
  cout << res << '\n';
}
int main() {
  Enter();
  Solve();
  return 0;
}
