#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<pair<long long, long long> > v[100005], g[100005];
long long dist[100005];
long long port[100005], np[100005];
pair<long long, pair<long long, long long> > p1[100005];
bool visited[100005];
void dijkstra(long long s) {
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  memset(visited, false, sizeof(visited));
  for (long long i = 1; i <= n; i++) {
    dist[i] = 1e18;
  }
  dist[s] = 0;
  pq.push({dist[s], s});
  while (!pq.empty()) {
    pair<long long, long long> p = pq.top();
    pq.pop();
    long long x = p.second;
    long long w = p.first;
    if (visited[x]) continue;
    visited[x] = true;
    for (long long i = 0; i < v[x].size(); i++) {
      long long y = v[x][i].second;
      long long d = v[x][i].first;
      if (dist[y] > dist[x] + d) {
        dist[y] = dist[x] + d;
        pq.push({dist[y], y});
        if (port[y]) {
          np[y] = y;
        } else {
          np[y] = np[x];
        }
      }
    }
  }
}
long long prim(long long s) {
  memset(visited, false, sizeof(visited));
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  long long mincost = 0;
  pq.push({0, s});
  while (!pq.empty()) {
    pair<long long, long long> p = pq.top();
    pq.pop();
    long long x = p.second;
    long long w = p.first;
    if (visited[x]) continue;
    visited[x] = true;
    mincost += w;
    for (long long i = 0; i < g[x].size(); i++) {
      if (!visited[g[x][i].second]) {
        pq.push(g[x][i]);
      }
    }
  }
  return mincost;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    v[x].push_back({w, y});
    v[y].push_back({w, x});
    p1[i].first = w;
    p1[i].second.first = x;
    p1[i].second.second = y;
  }
  long long k;
  cin >> k;
  long long z;
  for (long long i = 0; i < k; i++) {
    long long x;
    cin >> x;
    z = x;
    port[x] = 1;
    v[0].push_back({0, x});
  }
  dijkstra(0);
  for (long long i = 0; i < m; i++) {
    long long w = p1[i].first;
    long long x = p1[i].second.first;
    long long y = p1[i].second.second;
    long long w2 = dist[x] + w + dist[y];
    long long x2 = np[x];
    long long y2 = np[y];
    g[x2].push_back({w2, y2});
    g[y2].push_back({w2, x2});
  }
  long long ans = prim(z);
  if (port[1]) {
    cout << ans;
  } else {
    cout << ans + dist[1];
  }
}
