#include <bits/stdc++.h>
using namespace std;
const int MX = 100000 + 10;
const long long INF = 10000000000;
vector<long long> w[MX], adj[MX];
vector<pair<long long, pair<long long, long long> > > e, ee;
int n, m, cp[MX], port[MX];
long long d[MX], cost;
set<pair<long long, int> > a;
int compp(int v) {
  if (cp[v] == v) return v;
  return cp[v] = compp(cp[v]);
}
void merge(int u, int v) {
  cp[compp(u)] = cp[compp(v)];
  return;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0, u, v, ww; i < m; i++) {
    scanf("%d%d%d", &u, &v, &ww);
    adj[u].push_back(v);
    adj[v].push_back(u);
    w[u].push_back(ww);
    w[v].push_back(ww);
    ee.push_back(make_pair(ww, make_pair(v, u)));
  }
  for (int i = 1; i <= n; i++) d[i] = INF;
  int k;
  scanf("%d", &k);
  for (int i = 0, x; i < k; i++) {
    scanf("%d", &x);
    port[i] = x;
    d[x] = 0;
    cp[x] = x;
  }
  for (int i = 1; i <= n; i++) {
    a.insert(make_pair(d[i], i));
  }
  while ((int)a.size()) {
    int v = a.begin()->second;
    for (int i = 0; i < (int)adj[v].size(); i++) {
      if (d[adj[v][i]] > d[v] + w[v][i]) {
        a.erase(make_pair(d[adj[v][i]], adj[v][i]));
        d[adj[v][i]] = d[v] + w[v][i];
        a.insert(make_pair(d[adj[v][i]], adj[v][i]));
        cp[adj[v][i]] = cp[v];
      }
    }
    a.erase(make_pair(d[v], v));
  }
  for (int i = 0; i < (int)ee.size(); i++)
    if (cp[ee[i].second.first] != cp[ee[i].second.second]) {
      long long dis =
          d[ee[i].second.first] + d[ee[i].second.second] + ee[i].first;
      e.push_back(
          make_pair(dis, make_pair(ee[i].second.first, ee[i].second.second)));
    }
  ee.clear();
  sort(e.begin(), e.end());
  for (int i = 0; i < (int)e.size(); i++) {
    if (compp(e[i].second.first) != compp(e[i].second.second)) {
      merge(e[i].second.first, e[i].second.second);
      cost += e[i].first;
    }
  }
  cost += d[1];
  cout << cost << endl;
  return 0;
}
