#include <bits/stdc++.h>
using namespace std;
int mod = 998244353;
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int min(int a, int b) {
  if (a > b) return b;
  return a;
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
int lcm(int a, int b) { return ((a / gcd(a, b)) * b); }
int power(int a, int b) {
  int res = 1;
  while (b) {
    if (b % 2) {
      res = (res * 1LL * a) % mod;
    }
    b /= 2;
    a = (a * 1LL * a) % mod;
  }
  return res;
}
int par[2 * 100000 + 1];
int fin(int x) {
  if (par[x] == 0) return 0;
  if (par[x] == x) {
    return x;
  } else {
    int y = fin(par[x]);
    par[x] = y;
    return y;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  int w1 = 0;
  while (w1 < t) {
    w1++;
    int n, m;
    cin >> n >> m;
    int j = 0;
    long long int a[n + 1];
    par[0] = 0;
    long long int mi = 1e12 + 1;
    for (int i = 1; i < n + 1; i++) {
      par[i] = 0;
      cin >> a[i];
      if (a[i] < mi) {
        mi = a[i];
        j = i;
      }
    }
    std::vector<pair<long long int, pair<int, int>>> v;
    for (int i = 1; i < n + 1; i++) {
      if (i != j) v.push_back(make_pair(mi + a[i], make_pair(i, j)));
    }
    long long int x, y, z;
    for (int i = 0; i < m; i++) {
      cin >> x >> y >> z;
      v.push_back(make_pair(z, make_pair(x, y)));
    }
    sort(v.begin(), v.end());
    long long int ans = 0;
    int l = 0;
    int b = 0;
    while (l < n - 1) {
      z = v[b].first;
      x = (v[b].second).first;
      y = (v[b].second).second;
      int r = fin(x);
      int w = fin(y);
      if (r == 0 && w == 0) {
        ans += z;
        par[x] = x;
        par[y] = x;
        l++;
      } else if (r == 0) {
        ans += z;
        l++;
        par[x] = w;
      } else if (w == 0) {
        l++;
        ans += z;
        par[y] = r;
      } else {
        if (w != r) {
          l++;
          par[w] = r;
          ans += z;
        }
      }
      b++;
    }
    cout << ans;
    cout << "\n";
  }
  return 0;
}
