#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, pair<int, int>>> gg;
int tab[200001] = {0};
long long int weight = 0;
vector<pair<int, int>> adjacencyList[100000];
int V;
vector<int> visit;
int E;
int dfs_low[100000] = {0};
int dfsRoot = 0;
int rootChildren = 0;
int dfs_num[100000] = {0};
int dfs_parent[100000] = {0};
bool visited[100000] = {false};
int articulation_vertex[100000] = {0};
void dfs(int u) {
  visited[u] = 1;
  for (int i = 0; i < adjacencyList[u].size(); i++) {
    if (visited[adjacencyList[u][i].first] == 0) {
      dfs(adjacencyList[u][i].first);
    }
  }
}
long long int yo[200001];
int findx(int x) { return (tab[x] == x) ? x : (tab[x] = findx(tab[x])); }
void uniform(int x, int y) { tab[findx(x)] = findx(y); }
int main() {
  cin.tie(0);
  cin >> V >> E;
  long long int maxi = 1000000000001;
  long long int mini = 0;
  for (int i = 0; i < V; ++i) {
    cin >> yo[i];
    if (yo[i] < maxi) {
      maxi = yo[i];
      mini = i;
    }
  }
  for (int i = 0; i < E; ++i) {
    int x, y;
    long long int z;
    cin >> x >> y >> z;
    gg.push_back(make_pair(z, make_pair(x, y)));
  }
  for (int i = 1; i <= V; ++i) {
    if (mini + 1 != i)
      gg.push_back(make_pair(yo[i - 1] + yo[mini], make_pair(mini + 1, i)));
  }
  sort(gg.begin(), gg.end());
  for (int i = 1; i <= V; ++i) {
    tab[i] = i;
  }
  for (int i = 0; i < E + V - 1; ++i) {
    if (findx(gg[i].second.first) != findx(gg[i].second.second)) {
      weight += gg[i].first;
      uniform(gg[i].second.first, gg[i].second.second);
    }
  }
  cout << weight;
  return 0;
}
