#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
int n, m, tot, i, j, k, u, v, y[N], nxt[N], fst[N], f[N], p[N];
bool vis[N];
long long d[N], w[N], c, ans;
priority_queue<pair<long long, int> > q;
struct Edge {
  int u, v;
  long long c;
} E[N];
int find(int x) { return (f[x] == x) ? f[x] : f[x] = find(f[x]); }
void add(int u, int v, long long c) {
  y[tot] = v;
  nxt[tot] = fst[u];
  w[tot] = c;
  fst[u] = tot++;
}
bool cmp(Edge a, Edge b) { return a.c < b.c; }
int main() {
  scanf("%d%d", &n, &m);
  for (i = 0, tot = 1; i < m; i++)
    scanf("%d%d%I64d", &u, &v, &c), E[i] = (Edge){u, v, c}, add(u, v, c),
                                    add(v, u, c);
  memset(d, 50, sizeof(d));
  for (scanf("%d", &k); k; k--)
    scanf("%d", &u), d[u] = 0, p[u] = u, q.push(make_pair(0, u));
  while (q.size()) {
    while (vis[u = q.top().second] && q.size()) q.pop();
    if (q.empty()) break;
    vis[u] = 1;
    q.pop();
    for (j = fst[u]; j; j = nxt[j])
      if (d[u] + w[j] < d[y[j]]) {
        d[y[j]] = d[u] + w[j];
        p[y[j]] = p[u];
        q.push(make_pair(-d[y[j]], y[j]));
      }
  }
  for (i = 0; i < m; i++)
    E[i].c += d[E[i].u] + d[E[i].v],
        E[i] = (Edge){p[E[i].u], p[E[i].v], E[i].c};
  sort(E, E + m, cmp);
  for (i = 0; i < n; i++) f[i] = i;
  for (i = 0; i < m; i++)
    if (find(E[i].u) != find(E[i].v)) f[f[E[i].u]] = f[E[i].v], ans += E[i].c;
  printf("%I64d\n", ans + d[1]);
}
