#include <bits/stdc++.h>
using namespace std;
class UnionFind {
 private:
  vector<int> p;
  vector<int> rank;

 public:
  UnionFind(int N) {
    rank.assign(N, 1);
    p.resize(N);
    for (int i = 0; i < N; i++) p[i] = i;
  }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y]) {
        p[y] = x;
        rank[x] += rank[y];
      } else {
        p[x] = y;
        rank[y] += rank[x];
      }
    }
  }
};
const int N = 2e5 + 1e1;
vector<pair<long long, pair<int, int> > > EdgeList;
int n, m;
long long a[N];
int main() {
  int idx = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] < a[idx]) idx = i;
  }
  for (int i = idx + 1; i < n + idx; i++) {
    int j = i % n;
    EdgeList.push_back(make_pair(a[idx] + a[j], make_pair(idx, j)));
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    long long w;
    scanf("%d%d%lld", &x, &y, &w);
    x--, y--;
    EdgeList.push_back(make_pair(w, make_pair(x, y)));
  }
  sort(EdgeList.begin(), EdgeList.end());
  int sz = EdgeList.size();
  long long MSTcost = 0LL;
  UnionFind UF(n);
  for (unsigned int i = 0; i < sz; i++) {
    pair<long long, pair<int, int> > fr = EdgeList[i];
    if (!UF.isSameSet(fr.second.first, fr.second.second)) {
      MSTcost += fr.first;
      UF.unionSet(fr.second.first, fr.second.second);
    }
  }
  printf("%lld", MSTcost);
  return 0;
}
