#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 13;
const long long INF = 1e18 + 13;
int n, m, k;
set<pair<int, long long> > st;
vector<pair<int, int> > adj[Maxn];
vector<pair<long long, pair<int, int> > > edge, e;
long long sp[Maxn];
int par[Maxn], fa[Maxn], sz[Maxn];
bool mark[Maxn];
int ext_min() {
  pair<int, int> ret = *st.begin();
  st.erase(st.begin());
  return ret.second;
}
void add(int x) {
  for (auto a : adj[x]) {
    if (!mark[a.first]) {
      if (sp[a.first] > sp[x] + a.second) {
        st.erase({sp[a.first], a.first});
        sp[a.first] = sp[x] + a.second;
        st.insert({sp[a.first], a.first});
        par[a.first] = par[x];
      }
    }
  }
}
void dijk() {
  while (!st.empty()) {
    int x = ext_min();
    mark[x] = true;
    add(x);
  }
}
int getfa(int x) {
  if (x == fa[x]) return x;
  return getfa(fa[x]);
}
long long krus() {
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    sz[i] = 1;
  }
  sort(e.begin(), e.end());
  for (int i = 0; i < e.size(); i++) {
    int p = getfa(e[i].second.first), q = getfa(e[i].second.second);
    if (p != q) {
      ans += e[i].first;
      if (sz[p] < sz[q]) swap(p, q);
      sz[p] += sz[q];
      fa[q] = p;
    }
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    adj[x].push_back({y, w});
    adj[y].push_back({x, w});
    edge.push_back({w, {x, y}});
  }
  for (int i = 1; i <= n; i++) sp[i] = INF;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    sp[x] = 0;
    par[x] = x;
    add(x);
  }
  dijk();
  for (int i = 0; i < m; i++) {
    int a = edge[i].second.first, b = edge[i].second.second, w = edge[i].first;
    e.push_back({w + sp[a] + sp[b], {par[a], par[b]}});
  }
  cout << krus() + sp[1] << endl;
}
