#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000001;
const long long int LLINF = 1000000000000000001LL;
struct FAU {
  int cnt;
  vector<int> p, r;
  FAU(int n) : cnt(n), p(n, -1), r(n, 0) {}
  int Find(int x) {
    if (p[x] == -1) return x;
    return p[x] = Find(p[x]);
  }
  bool Together(int x, int y) { return (Find(x) == Find(y)); }
  void Union(int x, int y) {
    x = Find(x);
    y = Find(y);
    if (x == y) return;
    cnt--;
    if (r[x] > r[y])
      p[y] = x;
    else
      p[x] = y;
    if (r[x] == r[y]) ++r[y];
  }
  int Count() { return cnt; }
};
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int> > > G(n);
  for (int i = (1); i <= (m); ++i) {
    int u, v, len;
    cin >> u >> v >> len;
    u--;
    v--;
    G[u].push_back({v, len});
    G[v].push_back({u, len});
  }
  vector<bool> portal(n, 0);
  int k;
  cin >> k;
  while (k--) {
    int id;
    cin >> id;
    id--;
    portal[id] = 1;
  }
  vector<pair<long long int, int> > dist(n, {LLINF, -1});
  set<pair<pair<long long int, int>, int> > S;
  for (int i = (0); i <= (n - 1); ++i)
    if (portal[i]) {
      S.insert({{0, i}, i});
    }
  while (!S.empty()) {
    auto top = *S.begin();
    S.erase(S.begin());
    int v = top.second;
    if (dist[v].first != LLINF) continue;
    dist[v] = top.first;
    for (auto &edge : G[v]) {
      int u = edge.first;
      if (dist[u].first == LLINF) {
        S.insert({{top.first.first + edge.second, top.first.second}, u});
      }
    }
  }
  vector<pair<long long int, pair<int, int> > > edges;
  long long int sum = 0;
  for (int u = (0); u <= (n - 1); ++u)
    for (auto &edge : G[u]) {
      int v = edge.first;
      if (dist[u].second != dist[v].second) {
        edges.push_back({dist[u].first + edge.second + dist[v].first,
                         {dist[u].second, dist[v].second}});
      }
    }
  sort(edges.begin(), edges.end());
  FAU F(n);
  for (auto &edge : edges) {
    int u = edge.second.first, v = edge.second.second;
    if (!F.Together(u, v)) {
      sum += edge.first;
      F.Union(u, v);
    }
  }
  cout << dist[0].first + sum;
  return 0;
}
