#include <bits/stdc++.h>
using namespace std;
int N, E, K;
vector<pair<long long, long long> > graf[100005];
int par[100005], portal[100005];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
long long dis[100005];
vector<pair<long long, pair<long long, long long> > > edges;
bool vis[100005];
int findpar(int u) { return u == par[u] ? u : par[u] = findpar(par[u]); }
int main() {
  ios ::sync_with_stdio(false);
  for (int i = 0; i < 100005; i++) dis[i] = 1ll << 62;
  cin >> N >> E;
  for (int i = 1; i <= E; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    graf[u].push_back(make_pair(v, w));
    graf[v].push_back(make_pair(u, w));
  }
  cin >> K;
  for (int i = 1; i <= K; i++) {
    int x;
    cin >> x;
    portal[x] = par[x] = x;
    dis[x] = 0;
    q.push(make_pair(0, x));
  }
  while (!q.empty()) {
    pair<long long, long long> state = q.top();
    q.pop();
    int u = state.second;
    if (vis[u]) continue;
    vis[u] = 1;
    for (auto edge : graf[u]) {
      int v = edge.first;
      long long w = edge.second;
      if (portal[v])
        edges.push_back(
            make_pair(dis[u] + w + dis[v], make_pair(portal[u], portal[v])));
      if (dis[u] + w < dis[v]) {
        dis[v] = dis[u] + w;
        portal[v] = portal[u];
        q.push(make_pair(dis[v], v));
      }
    }
  }
  long long ans = dis[1];
  sort(edges.begin(), edges.end());
  for (auto e : edges) {
    long long w = e.first;
    int u = e.second.first;
    int v = e.second.second;
    u = findpar(u);
    v = findpar(v);
    if (u != v) {
      ans += w;
      par[u] = v;
    }
  }
  cout << ans << endl;
  return 0;
}
