#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
long long d[N];
int port[N], p[N];
vector<pair<int, int> > g[N];
vector<pair<long long, pair<int, int> > > e;
int dsu_get(int v) { return p[v] == v ? v : p[v] = dsu_get(p[v]); }
inline bool dsu_unite(int x, int y) {
  x = dsu_get(x);
  y = dsu_get(y);
  if (x != y) {
    p[x] = y;
    return true;
  } else {
    return false;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    g[x].push_back(make_pair(y, z));
    g[y].push_back(make_pair(x, z));
  }
  int k;
  cin >> k;
  set<pair<long long, int> > q;
  for (int i = 1; i <= n; i++) {
    d[i] = 9e18;
  }
  for (int i = 1; i <= k; i++) {
    int x;
    cin >> x;
    port[x] = x;
    d[x] = 0;
    q.insert(make_pair(0, x));
  }
  while (!q.empty()) {
    int v = q.begin()->second;
    q.erase(q.begin());
    for (auto it : g[v]) {
      int to = it.first, len = it.second;
      if (d[to] > d[v] + len) {
        q.erase(make_pair(d[to], to));
        d[to] = d[v] + len;
        port[to] = port[v];
        q.insert(make_pair(d[to], to));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (auto it : g[i]) {
      int to = it.first, len = it.second;
      e.push_back(make_pair(d[i] + len + d[to], make_pair(port[i], port[to])));
    }
  }
  for (int i = 1; i <= n; i++) {
    p[i] = i;
  }
  sort(e.begin(), e.end());
  long long ans = 0;
  for (auto it : e) {
    if (dsu_unite(it.second.first, it.second.second)) {
      ans += it.first;
    }
  }
  cout << ans + d[1];
}
