#include <bits/stdc++.h>
using namespace std;
class dsu {
 public:
  int n;
  vector<int> p;
  dsu(int n) : n(n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }
  int get(int x) { return x == p[x] ? x : p[x] = get(p[x]); }
  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<long long> a(n);
  for (auto& x : a) {
    scanf("%lld", &x);
  }
  long long mn = *min_element(a.begin(), a.end());
  int best = -1;
  for (int i = 0; i < n; ++i) {
    if (a[i] == mn) {
      best = i;
      break;
    }
  }
  vector<tuple<long long, int, int>> edges;
  for (int i = 0; i < m; ++i) {
    int x, y;
    long long z;
    scanf("%d %d %lld", &x, &y, &z);
    x--;
    y--;
    edges.emplace_back(z, x, y);
  }
  for (int i = 0; i < n; ++i) {
    edges.emplace_back(a[i] + a[best], i, best);
  }
  sort(edges.begin(), edges.end());
  dsu ds(n);
  long long ans = 0;
  for (const auto& e : edges) {
    if (ds.unite(get<1>(e), get<2>(e))) {
      ans += get<0>(e);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
