#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int from, to;
  long long len;
  Edge(int from, int to, long long len) : from(from), to(to), len(len) {}
  bool operator<(const Edge &rhs) const { return len < rhs.len; }
};
int n, m, K, portal[100001], fa[100001], nearest_portal[100001];
bool inque[100001];
long long dist[100001];
vector<Edge> edges, g[100001];
void init() {
  int x, y, len;
  cin >> n >> m;
  edges.clear();
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> len;
    g[x].push_back(Edge(x, y, len));
    g[y].push_back(Edge(y, x, len));
  }
  cin >> K;
  for (int i = 0; i < K; i++) cin >> portal[i];
}
void spfa() {
  memset(dist, 0x3f, sizeof(dist));
  queue<int> que;
  memset(inque, 0, sizeof(inque));
  for (int i = 0; i < n; i++) {
    que.push(portal[i]);
    dist[portal[i]] = 0;
    inque[portal[i]] = true;
    nearest_portal[portal[i]] = portal[i];
  }
  while (!que.empty()) {
    int node = que.front();
    for (__typeof(g[node].begin()) it = g[node].begin(); it != g[node].end();
         ++it)
      if (dist[it->from] + it->len < dist[it->to]) {
        dist[it->to] = dist[it->from] + it->len;
        nearest_portal[it->to] = nearest_portal[it->from];
        if (!inque[it->to]) {
          que.push(it->to);
          inque[it->to] = true;
        }
      }
    que.pop();
    inque[node] = false;
  }
}
void buildGraph() {
  edges.clear();
  for (int i = 1; i <= n; i++) {
    for (__typeof(g[i].begin()) it = g[i].begin(); it != g[i].end(); ++it)
      edges.push_back(Edge(nearest_portal[it->from], nearest_portal[it->to],
                           dist[it->from] + it->len + dist[it->to]));
  }
}
int findFather(int k) { return k != fa[k] ? fa[k] = findFather(fa[k]) : k; }
void kurskal() {
  long long len = 0;
  sort(edges.begin(), edges.end());
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (__typeof(edges.begin()) it = edges.begin(); it != edges.end(); ++it) {
    if (findFather(it->from) != findFather(it->to)) {
      fa[findFather(it->from)] = findFather(it->to);
      len += it->len;
    }
  }
  cout << len + dist[1] << endl;
}
void solve() {
  spfa();
  buildGraph();
  kurskal();
}
int main() {
  ios::sync_with_stdio(false);
  init();
  solve();
  return 0;
}
