#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MAX = 1e9 + 5;
int n, m, x, y, z, k, p[N], wh[N], node, root[N];
long long val, ans, sp[N], cost;
vector<pair<int, int> > v[N];
vector<pair<long long, pair<int, int> > > edges;
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
int findset(int node) {
  if (root[node] == node) return node;
  return root[node] = findset(root[node]);
}
void dijkstra() {
  while (!q.empty()) {
    node = q.top().second;
    val = q.top().first;
    q.pop();
    if (sp[node] < val) continue;
    for (__typeof(v[node].begin()) it = v[node].begin(); it != v[node].end();
         it++)
      if (sp[it->first] > sp[node] + it->second) {
        sp[it->first] = sp[node] + it->second;
        wh[it->first] = wh[node];
        q.push(make_pair(sp[it->first], it->first));
      }
  }
}
long long kruskal() {
  for (int i = 1; i <= n; i++)
    for (__typeof(v[i].begin()) it = v[i].begin(); it != v[i].end(); it++)
      if (it->first > i)
        edges.push_back(make_pair(sp[i] + it->second + sp[it->first],
                                  make_pair(wh[i], wh[it->first])));
  sort(edges.begin(), edges.end());
  for (__typeof(edges.begin()) it = edges.begin(); it != edges.end(); it++) {
    long long cost = it->first;
    long long x = it->second.first;
    long long y = it->second.second;
    if (findset(x) == findset(y)) continue;
    root[findset(x)] = findset(y);
    ans += cost;
  }
  return ans + sp[1];
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &x, &y, &z);
    v[x].push_back(make_pair(y, z));
    v[y].push_back(make_pair(x, z));
  }
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &p[i]);
    q.push(make_pair(0, p[i]));
    wh[p[i]] = p[i];
  }
  for (int i = 1; i <= n; i++) {
    root[i] = i;
    sp[i] = 1000000000000000000LL * (wh[i] == 0);
  }
  dijkstra();
  cout << kruskal();
  return 0;
}
