#include <bits/stdc++.h>
using namespace std;
long long res;
int Snm[110000], n, m;
set<pair<long long, int> > S;
long long D[110000];
int K[110000], e;
pair<long long, pair<int, int> > A[210000];
vector<pair<int, long long> > G[110000];
pair<long long, long long> p;
int SNM(int v) {
  if (Snm[v] == v) return v;
  Snm[v] = SNM(Snm[v]);
  return Snm[v];
}
void join(int a, int b, long long t) {
  a = SNM(a), b = SNM(b);
  if (a != b) {
    res += t;
    (rand() & 1) ? (Snm[a] = b) : (Snm[b] = a);
  }
}
int main() {
  int v1, v2, v, i, j, w, nv, x, k;
  long long lr;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++)
    scanf("%d%d%d", &v1, &v2, &w), v1--, v2--,
        G[v1].push_back(make_pair(v2, w)), G[v2].push_back(make_pair(v1, w));
  scanf("%d", &k);
  for (i = 0; i < n; i++)
    S.insert(make_pair(((long long)1e18), i)),
        Snm[i] = i, D[i] = ((long long)1e18), K[i] = -1;
  for (i = 0; i < k; i++)
    scanf("%d", &x), x--, S.erase(make_pair(((long long)1e18), x)),
        D[x] = 0, K[x] = x, S.insert(make_pair(0, x));
  while (S.size()) {
    p = *S.begin(), S.erase(S.begin());
    v = p.second;
    for (int i = 0; i < (int)G[v].size(); i++) {
      nv = G[v][i].first, lr = G[v][i].second;
      if (D[nv] > D[v] + lr)
        S.erase(make_pair(D[nv], nv)), D[nv] = D[v] + lr, K[nv] = K[v],
                                       S.insert(make_pair(D[nv], nv));
    }
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < (int)G[i].size(); j++) {
      v = G[i][j].first;
      if (K[i] != K[v])
        A[e++] = make_pair(D[i] + D[v] + G[i][j].second, make_pair(K[i], K[v]));
    }
  sort(A, A + e);
  for (i = 0; i < e; i++)
    join(A[i].second.first, A[i].second.second, A[i].first);
  printf("%I64d\n", res + D[0]);
  return 0;
}
