#include <bits/stdc++.h>
using namespace std;
const int maxN = (int)2e5 + 10;
const int maxM = (int)4e5 + 10;
int n, m, k, type[maxN], a[maxN], pa[maxN];
long long d[maxN];
vector<int> c[maxN], w[maxN];
set<pair<long long, int> > s;
int en, ea[maxM], eb[maxM], ep[maxM];
long long ew[maxM];
inline bool wless(int i, int j) { return ew[i] < ew[j]; }
int get(int v) { return v == pa[v] ? v : (pa[v] = get(pa[v])); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(m); i++) {
    int a, b, x;
    scanf("%d%d%d", &a, &b, &x), a--, b--;
    c[a].push_back(b), w[a].push_back(x);
    c[b].push_back(a), w[b].push_back(x);
  }
  scanf("%d", &k);
  for (int i = 0; i < (int)(n); i++) d[i] = (long long)1e18;
  for (int i = 0; i < (int)(k); i++) {
    scanf("%d", &a[i]), a[i]--;
    d[a[i]] = 0, type[a[i]] = i;
  }
  for (int i = 0; i < (int)(n); i++) s.insert(make_pair(d[i], i));
  while ((int)(s).size()) {
    int v = s.begin()->second;
    s.erase(s.begin());
    for (int i = 0; i < (int)((int)(c[v]).size()); i++) {
      int u = c[v][i];
      long long tmp = d[v] + w[v][i];
      if (d[u] > tmp) {
        s.erase(make_pair(d[u], u));
        d[u] = tmp, type[u] = type[v];
        s.insert(make_pair(d[u], u));
      }
    }
  }
  for (int v = 0; v < (int)(n); v++)
    for (int i = 0; i < (int)((int)(c[v]).size()); i++) {
      int u = c[v][i];
      if (type[v] != type[u]) {
        ea[en] = type[v];
        eb[en] = type[u];
        ep[en] = en;
        ew[en] = d[v] + d[u] + w[v][i];
        en++;
      }
    }
  long long ans = d[0];
  sort(ep, ep + en, wless);
  for (int i = 0; i < (int)(k); i++) pa[i] = i;
  for (int _i = 0; _i < (int)(en); _i++) {
    int i = ep[_i];
    if (get(ea[i]) != get(eb[i])) pa[get(ea[i])] = get(eb[i]), ans += ew[i];
  }
  printf("%I64d\n", ans);
  return 0;
}
