#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 10;
const long long INF = 1e15 + 10;
set<pair<long long, pair<long long, long long> > > s;
vector<pair<long long, long long> > vertex[MAXN];
vector<pair<long long, pair<long long, long long> > > edge;
long long e[MAXN];
long long dist[MAXN];
long long head[MAXN];
long long mst = 0;
void update(long long v) {
  if (head[head[v]] != head[head[head[v]]]) {
    update(head[v]);
  }
  head[v] = head[head[v]];
}
void dsu(long long v, long long u, long long w) {
  update(v);
  update(u);
  if (head[v] == head[u]) {
    return;
  }
  head[head[v]] = head[u];
  mst += w;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long v, u, w;
    cin >> v >> u >> w;
    vertex[v].push_back(make_pair(u, w));
    vertex[u].push_back(make_pair(v, w));
  }
  long long k;
  cin >> k;
  for (long long i = 0; i < k; i++) {
    long long v;
    cin >> v;
    s.insert(make_pair(0LL, make_pair(v, v)));
  }
  fill(dist, dist + MAXN, INF);
  while (!s.empty()) {
    long long v = (s.begin()->second).first, u = (s.begin()->second).second,
              w = s.begin()->first;
    s.erase(s.begin());
    if (dist[v] != INF) {
      continue;
    }
    e[v] = u;
    dist[v] = w;
    for (long long i = 0; i < vertex[v].size(); i++) {
      if (dist[vertex[v][i].first] == INF) {
        s.insert(make_pair(dist[v] + vertex[v][i].second,
                           make_pair(vertex[v][i].first, e[v])));
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    head[i] = i;
    for (long long j = 0; j < vertex[i].size(); j++) {
      edge.push_back(
          make_pair(dist[i] + dist[vertex[i][j].first] + vertex[i][j].second,
                    make_pair(e[vertex[i][j].first], e[i])));
    }
  }
  sort(edge.begin(), edge.end());
  for (long long i = 0; i < edge.size(); i++) {
    dsu(edge[i].second.first, edge[i].second.second, edge[i].first);
  }
  cout << dist[1] + mst;
}
