#include <bits/stdc++.h>
using namespace std;
const long long inf = 100000000000000000LL;
const double pi = acos(-1.0);
int n, m, k, i, j;
int head[200000], ev[1000000], nxt[1000000], edge;
long long ew[1000000], d[200000];
int p[200000], fa[200000];
bool is[200000], vis[200000];
int q[4000000], bg, ed;
struct item {
  int u, v;
  long long w;
  bool operator<(const item &a) const { return w < a.w; }
} a[200000];
int find(int u) {
  if (u == fa[u])
    return u;
  else
    return fa[u] = find(fa[u]);
}
void add(int u, int v, long long w) {
  ev[++edge] = v;
  ew[edge] = w;
  nxt[edge] = head[u];
  head[u] = edge;
}
void spfa() {
  bg = ed = 0;
  for (int i = 1; i <= n; i++) {
    if (!is[i])
      d[i] = inf, vis[i] = false;
    else {
      d[i] = 0;
      vis[i] = 1;
      p[i] = i;
      q[ed++] = i;
    }
  }
  while (bg < ed) {
    int u = q[bg++];
    vis[u] = 0;
    for (int i = head[u]; i != -1; i = nxt[i]) {
      int v = ev[i];
      if (d[u] + ew[i] < d[v]) {
        d[v] = d[u] + ew[i];
        p[v] = p[u];
        if (!vis[v]) {
          vis[v] = 1;
          q[ed++] = v;
        }
      }
    }
  }
}
long long kruscal() {
  long long ans = 0;
  sort(a + 1, a + m + 1);
  for (i = 1; i <= n; i++) fa[i] = i;
  for (i = 1; i <= m; i++) {
    int u = a[i].u, v = a[i].v;
    long long w = a[i].w;
    u = p[u], v = p[v];
    if (find(u) != find(v)) {
      fa[fa[u]] = v;
      ans += w;
    }
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  memset(head, -1, sizeof(head));
  edge = -1;
  for (i = 1; i <= m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%I64d", &u, &v, &w);
    add(u, v, w);
    add(v, u, w);
    a[i].u = u;
    a[i].v = v;
    a[i].w = w;
  }
  scanf("%d", &k);
  for (i = 1; i <= k; i++) {
    int u;
    scanf("%d", &u);
    is[u] = 1;
  }
  spfa();
  long long ans = d[1];
  for (i = 1; i <= m; i++) {
    a[i].w += d[a[i].u] + d[a[i].v];
  }
  ans += kruscal();
  printf("%I64d\n", ans);
  return 0;
}
