#include <bits/stdc++.h>
using namespace std;
void bug() { cout << " " << endl; }
template <class T>
void bug(T a) {
  cout << a << "  ";
}
template <class T>
void bug(T* a, int n) {
  for (int i = 0; i < (n); i++) bug(a[i]);
}
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
int n, m;
vector<pair<int, long long> > g[1111111];
long long d[1111111];
int mark[1111111], fa[1111111];
vector<pair<long long, pair<int, int> > > e;
int find(int u) {
  if (u == fa[u])
    return u;
  else
    return fa[u] = find(fa[u]);
}
void update(int u, long long dist, int m) {
  if (dist < d[u]) {
    d[u] = dist;
    mark[u] = m;
    q.push(make_pair(dist, u));
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    int x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    g[x].push_back(make_pair(y, w));
    g[y].push_back(make_pair(x, w));
  }
  for (int i = 0; i < (n); i++) d[i] = 1000000000000000000LL;
  int k;
  cin >> k;
  for (int i = 0; i < (k); i++) {
    int x;
    cin >> x;
    mark[x - 1] = x - 1;
    update(x - 1, 0, x - 1);
  }
  while (q.size() > 0) {
    pair<long long, int> p = q.top();
    q.pop();
    long long dist = p.first;
    int u = p.second;
    if (d[u] != dist) continue;
    for (int i = 0; i < (g[u].size()); i++) {
      int v = g[u][i].first;
      update(v, g[u][i].second + dist, mark[u]);
    }
  }
  long long ans = d[0];
  for (int u = 0; u < (n); u++)
    for (int i = 0; i < (g[u].size()); i++) {
      int v = g[u][i].first;
      if (u < v && mark[u] != mark[v])
        e.push_back(make_pair(d[u] + d[v] + g[u][i].second,
                              make_pair(mark[u], mark[v])));
    }
  sort(e.begin(), e.end());
  for (int i = 0; i < (n); i++) fa[i] = i;
  for (int i = 0; i < (e.size()); i++) {
    int u = e[i].second.first, v = e[i].second.second;
    long long cost = e[i].first;
    if (find(u) != find(v)) {
      ans += cost;
      fa[find(u)] = find(v);
    }
  }
  cout << ans << endl;
  return 0;
}
