#include <bits/stdc++.h>
using namespace std;
typedef class Edge {
 public:
  int u, v;
  long long w;
  Edge() {}
  Edge(int u, int v, long long w) : u(u), v(v), w(w) {}
  void read() { scanf("%d%d%lld", &u, &v, &w); }
  bool operator<(Edge b) const { return w < b.w; }
} Edge;
typedef class Node {
 public:
  int p;
  long long d;
  int org;
  Node(int p, long long d, int org) : p(p), d(d), org(org) {}
  bool operator<(Node b) const { return d > b.d; }
} Node;
const long long llf = (~0ull >> 2);
const int N = 1e5 + 5;
int n, m;
bool iskey[N];
vector<pair<int, int> > G[N];
vector<Edge> E, E0;
long long f[N];
int g[N];
void dijkstra() {
  priority_queue<Node> Q;
  for (int i = 1; i <= n; i++) {
    if (iskey[i]) {
      Q.push(Node(i, f[i] = 0, g[i] = i));
    } else {
      f[i] = llf;
    }
  }
  while (!Q.empty()) {
    Node e = Q.top();
    Q.pop();
    if (e.d ^ f[e.p]) continue;
    for (auto _ : G[e.p]) {
      int q = _.first;
      int w = _.second;
      if (f[e.p] + w < f[q]) {
        Q.push(Node(q, f[q] = f[e.p] + w, g[q] = e.org));
      }
    }
  }
}
int uf[N];
int find(int x) { return uf[x] == x ? (x) : (uf[x] = find(uf[x])); }
long long kruskal() {
  for (int i = 1; i <= n; i++) uf[i] = i;
  sort(E.begin(), E.end());
  long long ret = 0;
  for (auto e : E) {
    int u = find(e.u), v = find(e.v);
    if (u ^ v) {
      uf[u] = v;
      ret += e.w;
    }
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  E0.resize(m);
  for (int i = 0; i < m; i++) {
    E0[i].read();
    G[E0[i].u].emplace_back(E0[i].v, (int)E0[i].w);
    G[E0[i].v].emplace_back(E0[i].u, (int)E0[i].w);
  }
  int cnt, x;
  scanf("%d", &cnt);
  while (cnt--) {
    scanf("%d", &x);
    iskey[x] = true;
  }
  dijkstra();
  for (auto e : E0) {
    if (g[e.u] ^ g[e.v]) {
      E.emplace_back(g[e.u], g[e.v], f[e.u] + f[e.v] + e.w);
    }
  }
  long long ans = kruskal() + f[1];
  printf("%lld\n", ans);
  return 0;
}
