#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
const long long inf = 1e18;
int n, m, k;
vector<pair<int, int> > adj[maxn];
vector<pair<long long, long long> > vadj[maxn];
bool por[maxn];
long long dist[maxn];
int near[maxn];
bool vis[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    adj[a].push_back(pair<int, int>(b, c));
    adj[b].push_back(pair<int, int>(a, c));
  }
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  cin >> k;
  for (int i = 1; i <= n; i++) dist[i] = inf;
  for (int i = 0; i < k; i++) {
    int p;
    cin >> p;
    por[p] = 1;
    pq.push(pair<long long, long long>(0, p));
    near[p] = p;
    dist[p] = 0;
  }
  while (!pq.empty()) {
    long long d = pq.top().first;
    int x = pq.top().second;
    pq.pop();
    if (vis[x]) continue;
    vis[x] = 1;
    for (pair<int, int> p : adj[x])
      if (d + p.second < dist[p.first])
        dist[p.first] = d + p.second, near[p.first] = near[x],
        pq.push(pair<long long, long long>(d + p.second, p.first));
  }
  for (int i = 1; i <= n; i++)
    for (pair<int, int> p : adj[i])
      if (near[i] != near[p.first])
        vadj[near[i]].push_back(pair<long long, long long>(
            near[p.first], dist[i] + dist[p.first] + p.second));
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (por[i]) {
      pq.push(pair<long long, long long>(0, i));
      break;
    }
  memset(vis, 0, sizeof(vis));
  while (!pq.empty()) {
    long long d = pq.top().first;
    int x = pq.top().second;
    pq.pop();
    if (vis[x]) continue;
    vis[x] = 1;
    ans += d;
    for (pair<long long, long long> p : vadj[x])
      pq.push(pair<long long, long long>(p.second, p.first));
  }
  cout << ans + dist[1] << '\n';
}
