#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int MAXM = 100010;
const long long INF = 1e14;
struct Node {
  int to, next, w;
} e[MAXM * 2];
struct Enode {
  int a, b;
  long long w;
  Enode() {}
  Enode(int a, int b, long long w) : a(a), b(b), w(w) {}
  bool operator<(const Enode &that) const { return w < that.w; }
} tree[MAXM * 2];
int n, m, k, box[MAXN], size;
int x[MAXN], pre[MAXN];
bool flag[MAXN];
int p[MAXN];
long long dis[MAXN];
void add(int from, int to, int w) {
  e[size].to = to;
  e[size].w = w;
  e[size].next = box[from];
  box[from] = size++;
}
void init() {
  scanf("%d%d", &n, &m);
  memset(box, -1, sizeof(box)), size = 0;
  for (int i = 0, a, b, w; i < m; ++i) {
    scanf("%d%d%d", &a, &b, &w);
    add(a, b, w), add(b, a, w);
  }
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) scanf("%d", &x[i]);
}
void spfa() {
  queue<int> Q;
  memset(flag, false, sizeof(flag));
  fill(dis + 1, dis + n + 1, INF);
  for (int i = 0; i < k; ++i) {
    Q.push(x[i]);
    pre[x[i]] = x[i];
    flag[x[i]] = true;
    dis[x[i]] = 0;
  }
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    flag[x] = false;
    for (int i = box[x]; ~i; i = e[i].next)
      if (dis[e[i].to] - dis[x] > e[i].w) {
        dis[e[i].to] = dis[x] + e[i].w;
        pre[e[i].to] = pre[x];
        if (!flag[e[i].to]) flag[e[i].to] = true, Q.push(e[i].to);
      }
  }
}
int findSet(int x) {
  if (p[x] != x) p[x] = findSet(p[x]);
  return p[x];
}
void solve() {
  spfa();
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = box[i]; ~j; j = e[j].next)
      tree[cnt++] = Enode(pre[i], pre[e[j].to], dis[i] + dis[e[j].to] + e[j].w);
  for (int i = 1; i <= n; ++i) p[i] = i;
  sort(tree, tree + cnt);
  long long ans = 0;
  for (int i = 0; i < cnt; ++i) {
    int a = findSet(tree[i].a), b = findSet(tree[i].b);
    if (a != b) p[a] = b, ans += tree[i].w;
  }
  cout << ans + dis[1] << endl;
}
int main() {
  init();
  solve();
  return 0;
}
