#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> edge[(100005)];
int ea[(100005)];
int eb[(100005)];
int esum[(100005)];
int ecost[(100005)];
int K;
long long D[(100005)];
int P[(100005)];
priority_queue<pair<long long, int> > PQ;
vector<pair<long long, int> > sp;
int ss[(100005)];
int sn[(100005)];
void reset_set() {
  for (int i = 0; i < N; ++i) {
    ss[i] = i;
    sn[i] = 1;
  }
}
int find_set(int a) {
  if (a != ss[a]) ss[a] = find_set(ss[a]);
  return ss[a];
}
int union_set(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (sn[a] < sn[b]) a ^= b ^= a ^= b;
    ss[b] = a;
    sn[a] += sn[b];
    return 1;
  } else
    return 0;
}
int main() {
  int i;
  scanf("%d %d", &N, &M);
  for (i = 0; i < M; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    --a;
    --b;
    ea[i] = a;
    eb[i] = b;
    esum[i] = a + b;
    ecost[i] = c;
    edge[a].push_back(i);
    edge[b].push_back(i);
  }
  memset(D, -1, sizeof(D));
  scanf("%d", &K);
  for (i = 0; i < K; ++i) {
    int a;
    scanf("%d", &a);
    --a;
    D[a] = 0;
    P[a] = a;
    PQ.push(pair<long long, int>(0, a));
  }
  while (!PQ.empty()) {
    pair<long long, int> p = PQ.top();
    PQ.pop();
    long long d = -p.first;
    int a = p.second;
    if (d != D[a]) continue;
    int sz = edge[a].size();
    for (i = 0; i < sz; ++i) {
      int e = edge[a][i];
      int b = esum[e] - a;
      int c = ecost[e];
      if (D[b] == -1 || D[b] > d + c) {
        D[b] = d + c;
        P[b] = P[a];
        PQ.push(pair<long long, int>(-D[b], b));
      }
    }
  }
  for (i = 0; i < M; ++i) {
    int a = ea[i];
    int b = eb[i];
    if (P[a] != P[b])
      sp.push_back(pair<long long, int>(D[a] + D[b] + ecost[i], i));
  }
  sort(sp.begin(), sp.end());
  reset_set();
  long long sol = D[0];
  int sz = sp.size();
  for (i = 0; i < sz; ++i) {
    int e = sp[i].second;
    int a = P[ea[e]];
    int b = P[eb[e]];
    if (union_set(a, b)) sol += sp[i].first;
  }
  printf("%I64d\n", sol);
  return 0;
}
