#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 100, INF = 1e18;
long long n, m, k, d[MAXN], p[MAXN], par[MAXN];
vector<pair<long long, pair<long long, long long>>> E, edge;
vector<pair<long long, long long>> adj[MAXN];
void Dij() {
  set<pair<long long, long long>> st;
  for (long long i = 0; i < n; i++) st.insert({d[i], i}), p[i] = i;
  while (!st.empty()) {
    long long u = (*st.begin()).second;
    st.erase(st.begin());
    for (auto x : adj[u]) {
      if (d[x.first] > d[u] + x.second) {
        st.erase({d[x.first], x.first});
        d[x.first] = d[u] + x.second;
        p[x.first] = p[u];
        st.insert({d[x.first], x.first});
      }
    }
  }
}
void find_edge() {
  for (auto x : E) {
    long long w = x.first, u = x.second.first, v = x.second.second;
    if (p[u] != p[v]) edge.push_back({d[u] + w + d[v], {p[u], p[v]}});
  }
  sort(edge.begin(), edge.end());
}
long long root(long long x) {
  return (par[x] == x ? x : par[x] = root(par[x]));
}
bool merge(long long x, long long y) {
  x = root(x), y = root(y);
  if (x == y) return 0;
  par[x] = y;
  return 1;
}
long long MST() {
  long long res = 0;
  for (auto x : edge) {
    if (merge(x.second.first, x.second.second)) res += x.first;
  }
  return res;
}
int32_t main() {
  fill(d, d + MAXN, INF);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
    E.push_back({w, {u, v}});
  }
  cin >> k;
  for (long long i = 0; i < k; i++) {
    long long x;
    cin >> x;
    x--;
    d[x] = 0;
  }
  Dij();
  find_edge();
  iota(par, par + MAXN, 0);
  cout << d[0] + MST() << endl;
}
