#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000 * 1000 * 1000ll * 1000 * 1000ll * 1000ll + 10;
const int N = 1000 * 100 + 3;
vector<long long> w[N];
vector<int> adj[N];
int n, k, m;
int port[N];
int par[N];
long long dis[N];
vector<pair<long long, pair<int, int> > > edges;
long long sum;
struct cmp {
  bool operator()(const int &a, const int &b) {
    if (dis[a] != dis[b]) return dis[a] < dis[b];
    return a < b;
  }
};
void dij() {
  fill(dis, dis + N, INF);
  set<int, cmp> s;
  for (int i = 0; i < k; i++) {
    dis[port[i]] = 0;
    par[port[i]] = port[i];
    s.insert(port[i]);
  }
  while (s.size()) {
    int v = *(s.begin());
    s.erase(v);
    for (int i = 0; i < adj[v].size(); i++) {
      int u = adj[v][i];
      long long c = w[v][i];
      if (dis[u] > dis[v] + c) {
        s.erase(u);
        dis[u] = dis[v] + c;
        par[u] = par[v];
        s.insert(u);
      }
    }
  }
  return;
}
void make_new_graph() {
  for (int v = 0; v < n; v++) {
    for (int i = 0; i < adj[v].size(); i++) {
      int u = adj[v][i];
      long long c = w[v][i];
      c = dis[u] + dis[v] + c;
      if (v < u)
        edges.push_back(
            pair<long long, pair<int, int> >(c, pair<int, int>(v, u)));
    }
  }
  return;
}
int parent(int x) {
  if (x == par[x]) return x;
  return par[par[x]] = parent(par[x]);
}
bool merge(int a, int b) {
  a = parent(a);
  b = parent(b);
  if (a == b) return false;
  par[a] = b;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    adj[a].push_back(b);
    w[a].push_back(c);
    adj[b].push_back(a);
    w[b].push_back(c);
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> port[i];
    port[i]--;
  }
  dij();
  make_new_graph();
  sort(edges.begin(), edges.end());
  for (int i = 0; i < edges.size(); i++) {
    int v = edges[i].second.first, u = edges[i].second.second;
    if (merge(v, u)) {
      sum += edges[i].first;
    }
  }
  cout << sum + dis[0] << endl;
  return 0;
}
