#include <bits/stdc++.h>
using namespace std;
int n, m;
long long int d[100009];
int p[100009];
vector<pair<long long int, int> > v[100009];
vector<pair<long long int, int> > w[100009];
bool e[100009];
bool mask[100009];
long long int res;
priority_queue<pair<long long int, int> > tq;
int find_i(int si, int sj) {
  int l, r;
  l = 0;
  r = w[si].size();
  int mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (w[si][mid].second == sj)
      return mid;
    else if (w[si][mid].second < sj)
      l = mid + 1;
    else
      r = mid;
  }
  return l;
}
void process() {
  int i, j, k;
  for (i = 0; i < n; i++) {
    if (e[i]) {
      d[i] = 0;
      p[i] = i;
      tq.push(pair<long long int, int>(0, i));
    } else
      d[i] = 1000000000000000LL;
  }
  while (!tq.empty()) {
    pair<long long int, int> tt = tq.top();
    tq.pop();
    int tj = tt.second;
    long long int tm = -tt.first;
    if (d[tj] < tm) continue;
    if (e[tj]) {
      res += d[tj];
      d[tj] = 0;
      tm = 0;
    }
    for (i = 0; i < v[tj].size(); i++) {
      long long int qm = v[tj][i].first;
      j = v[tj][i].second;
      if (d[j] > d[tj] + qm) {
        d[j] = d[tj] + qm;
        p[j] = p[tj];
        tq.push(pair<long long int, int>(-d[j], j));
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < v[i].size(); j++) {
      k = v[i][j].second;
      w[p[i]].push_back(
          pair<long long int, int>(d[i] + d[k] + v[i][j].first, p[k]));
      w[p[k]].push_back(
          pair<long long int, int>(d[i] + d[k] + v[i][j].first, p[i]));
    }
  }
  res = d[0];
  while (!tq.empty()) tq.pop();
  tq.push(pair<long long int, int>(0, p[0]));
  while (!tq.empty()) {
    pair<long long int, int> tt = tq.top();
    tq.pop();
    int tj = tt.second;
    long long int tm = -tt.first;
    if (mask[tj]) continue;
    mask[tj] = true;
    res += tm;
    for (i = 0; i < w[tj].size(); i++) {
      j = w[tj][i].second;
      if (!mask[j]) tq.push(pair<long long int, int>(-w[tj][i].first, j));
    }
  }
  printf("%I64d\n", res);
}
int main() {
  int i, j, k;
  scanf("%d %d", &n, &m);
  while (m--) {
    scanf("%d %d %d", &i, &j, &k);
    i--;
    j--;
    v[i].push_back(pair<long long int, int>(k, j));
    v[j].push_back(pair<long long int, int>(k, i));
  }
  scanf("%d", &k);
  for (i = 0; i < k; i++) {
    scanf("%d", &j);
    j--;
    e[j] = true;
  }
  process();
}
