#include <bits/stdc++.h>
using namespace std;
const long long sqrInf = (long long)(1e18) - 1;
int k;
long long rez;
int n, m;
int ant[100000 + 1];
long long dp[100000 + 1];
priority_queue<pair<long long, int>, vector<pair<long long, int>>,
               greater<pair<long long, int>>>
    q;
bitset<100000 + 1> p;
bitset<100000 + 1> viz;
vector<pair<int, int>> g[100000 + 1];
void add(int a, int b, int c) { g[a].push_back({b, c}); }
struct elem {
  int x, y;
  long long c;
};
struct cmp {
  bool operator()(const elem &a, const elem &b) const { return a.c < b.c; }
};
elem v[100000 + 1];
void readFile() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  int a, b, c;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b >> c;
    add(a, b, c);
    add(b, a, c);
  }
  cin >> k;
  int x;
  for (int i = 1; i <= k; i++) {
    cin >> x;
    p[x] = 1;
  }
}
void getDistra() {
  for (int i = 1; i <= n; i++) dp[i] = sqrInf;
  for (int i = 1; i <= n; i++) {
    if (p[i] == 1) {
      dp[i] = 0;
      ant[i] = i;
      q.push({0, i});
    }
  }
  while (q.size() > 0) {
    int nod = q.top().second;
    q.pop();
    if (viz[nod] == 0) {
      viz[nod] = 1;
      for (auto u : g[nod]) {
        if (dp[u.first] > dp[nod] + u.second) {
          ant[u.first] = ant[nod];
          dp[u.first] = dp[nod] + u.second;
          q.push({dp[u.first], u.first});
        }
      }
    }
  }
}
int comp[100000 + 1];
int h[100000 + 1];
int getComp(int a) { return (comp[a] = (comp[a] == a ? a : getComp(comp[a]))); }
void uneste(int a, int b) {
  if (h[a] < h[b]) swap(a, b);
  if (h[a] == h[b]) h[a]++;
  comp[b] = a;
}
void getRez() {
  int k = 0;
  for (int i = 1; i <= n; i++) {
    for (auto u : g[i]) {
      if (i < u.first && ant[i] != ant[u.first])
        v[++k] = {ant[i], ant[u.first], u.second + dp[i] + dp[u.first]};
    }
  }
  sort(v + 1, v + k + 1, cmp());
  for (int i = 1; i <= n; i++) {
    comp[i] = i;
    h[i] = 1;
  }
  for (int i = 1; i <= k; i++) {
    int ca = getComp(comp[v[i].x]);
    int cb = getComp(comp[v[i].y]);
    if (ca != cb) {
      rez += v[i].c;
      uneste(ca, cb);
    }
  }
  rez += dp[1];
}
void solve() {
  getDistra();
  getRez();
}
void printFile() { cout << rez << "\n"; }
int main() {
  readFile();
  solve();
  printFile();
  return 0;
}
