#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + c - 48;
    c = getchar();
  }
  return x * f;
}
const int N = 1e5 + 7;
struct cow {
  int v, next;
  long long w;
} E[N << 2];
int head[N], tot;
void add(int u, int v, long long w) {
  E[++tot].v = v;
  E[tot].w = w;
  E[tot].next = head[u];
  head[u] = tot;
  E[++tot].v = u;
  E[tot].w = w;
  E[tot].next = head[v];
  head[v] = tot;
}
long long dis[N];
int pre[N], val[N], vis[N];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    Q;
void DIJ(int s) {
  memset(dis, 0x3f, sizeof dis);
  dis[s] = 0;
  pre[s] = 1;
  Q.push(make_pair(dis[s], s));
  while (!Q.empty()) {
    pair<long long, int> p = Q.top();
    Q.pop();
    int u = p.second;
    if (p.first != dis[u]) continue;
    for (int i = head[u]; i; i = E[i].next) {
      int v = E[i].v;
      if (dis[v] > dis[u] + E[i].w) {
        dis[v] = dis[u] + E[i].w;
        pre[v] = pre[u] * val[v];
        Q.push(make_pair(dis[v], v));
      }
    }
  }
}
struct edge {
  int u, v;
  long long w;
  void ins() { add(u, v, w); }
} C[N << 2];
bool cmp(edge a, edge b) { return a.w < b.w; }
long long ans = 0;
int u[N], v[N], w[N];
int fa[N];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  int n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    C[i].u = read();
    C[i].v = read();
    C[i].w = read();
    C[i].ins();
  }
  DIJ(1);
  int k = read();
  ans = INT_MAX;
  for (int i = 1; i <= n; i++) val[i] = 1, fa[i] = i;
  for (int i = 1; i <= k; i++) {
    int x = read();
    val[x] = x;
    vis[x] = 1;
    ans = min(ans, dis[x]);
    add(0, x, 0);
  }
  DIJ(0);
  for (int i = 1; i <= m; i++) {
    C[i].w += dis[C[i].u] + dis[C[i].v];
    C[i].u = pre[C[i].u];
    C[i].v = pre[C[i].v];
  }
  sort(C + 1, C + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int u = C[i].u, v = C[i].v;
    if (!vis[u] || !vis[v]) continue;
    if (find(u) == find(v)) continue;
    fa[find(u)] = find(v);
    ans += C[i].w;
  }
  printf("%lld\n", ans);
  return 0;
}
