#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int n, m, k, par[N], portal[N];
long long dist[N];
vector<pair<int, int> > gr[N];
vector<pair<int, pair<int, int> > > edges;
vector<pair<long long, pair<int, int> > > new_edges;
inline int get(int x) {
  if (par[x] < 0) return x;
  return par[x] = get(par[x]);
}
inline bool unin(int x, int y) {
  x = get(x);
  y = get(y);
  if (x == y) return false;
  par[x] += par[y];
  par[y] = x;
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    gr[a].push_back({c, b});
    gr[b].push_back({c, a});
    edges.push_back({c, {a, b}});
  }
  for (int i = 1; i <= n; i++) {
    dist[i] = 1e18;
    par[i] = -1;
  }
  set<pair<long long, int> > q;
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    int p;
    scanf("%d", &p);
    dist[p] = 0;
    portal[p] = p;
    q.insert({0, p});
  }
  while (!q.empty()) {
    auto pp = *q.begin();
    q.erase(pp);
    int v = pp.second;
    for (auto pp : gr[v]) {
      int cost = pp.first, to = pp.second;
      if (dist[to] > dist[v] + cost) {
        q.erase({dist[to], to});
        dist[to] = dist[v] + cost;
        portal[to] = portal[v];
        q.insert({dist[to], to});
      }
    }
  }
  for (int i = 1; i <= n; i++) gr[i].clear();
  for (auto edge : edges) {
    int cost = edge.first, a = edge.second.first, b = edge.second.second;
    if (portal[a] == portal[b]) continue;
    new_edges.push_back({dist[a] + dist[b] + cost, {portal[a], portal[b]}});
  }
  sort(new_edges.begin(), new_edges.end());
  long long ans = dist[1];
  for (auto edge : new_edges) {
    long long cost = edge.first;
    int a = edge.second.first, b = edge.second.second;
    if (unin(a, b)) {
      ans += cost;
    }
  }
  printf("%lld\n", ans);
}
