#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int ne[N << 1], first[N], zz[N << 1], sl[N << 1], tot, n, m, x, y, z, l, fa[N],
    vis[N];
pair<long long, long long> f[N * 3], dis[N];
struct Ask {
  int x, y;
  long long z;
} A[N];
void jb(int x, int y, int z) {
  ne[++tot] = first[x];
  first[x] = tot;
  zz[tot] = y;
  sl[tot] = z;
}
void down(int x) {
  int i = x;
  if (x * 2 <= l && f[x * 2] < f[x]) i = x * 2;
  if (x * 2 < l && f[x * 2 + 1] < f[i]) i = x * 2 + 1;
  if (i != x) {
    swap(f[x], f[i]);
    down(i);
  }
}
void up(int x) {
  if (x == 1) return;
  if (f[x / 2] > f[x]) {
    swap(f[x / 2], f[x]);
    up(x / 2);
  }
}
int find(int x) {
  if (x == fa[x]) return x;
  return fa[x] = find(fa[x]);
}
int cmp(Ask x, Ask y) { return x.z < y.z; }
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d%d", &x, &y, &z);
    jb(x, y, z);
    jb(y, x, z);
  }
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) dis[i] = make_pair(1e18, -1);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &x);
    dis[x] = make_pair(0, i);
    fa[i] = i;
  }
  for (int i = 1; i <= n; i++) f[++l] = make_pair(dis[i].first, i);
  for (int i = n; i; i--) down(i);
  long long last = 0;
  while (l) {
    int k = f[1].second;
    f[1] = f[l--];
    down(1);
    if (vis[k]) continue;
    vis[k] = 1;
    for (int i = first[k]; i; i = ne[i])
      if (dis[zz[i]].first > dis[k].first + sl[i]) {
        dis[zz[i]].first = dis[k].first + sl[i];
        dis[zz[i]].second = dis[k].second;
        f[++l] = make_pair(dis[zz[i]].first, zz[i]);
        up(l);
      }
  }
  long long ans = 0;
  tot = 0;
  for (int i = 1; i <= n; i++)
    for (int j = first[i]; j; j = ne[j])
      if (zz[j] > i && dis[zz[j]].second != dis[i].second)
        A[++tot].x = dis[i].second, A[tot].y = dis[zz[j]].second,
        A[tot].z = dis[zz[j]].first + dis[i].first + sl[j];
  sort(A + 1, A + tot + 1, cmp);
  for (int i = 1; i <= tot; i++) {
    int x = find(A[i].x), y = find(A[i].y);
    long long z = A[i].z;
    if (x != y) fa[x] = y, ans += z;
  }
  printf("%lld\n", ans + dis[1].first);
}
