#include <bits/stdc++.h>
using namespace std;
const long long infll = 0x3f3f3f3f3f3f3f3fll;
const int N = 1e5 + 7;
int n, m, k, vis[N], which[N];
long long d[N];
struct Edge {
  long long w;
  int u, v;
};
vector<Edge> edges;
vector<pair<int, long long>> g[N];
bool cmp(const Edge& lhs, const Edge& rhs) { return lhs.w < rhs.w; }
void dij(int s) {
  memset(d, infll, sizeof(d));
  priority_queue<pair<long long, pair<int, int>>,
                 vector<pair<long long, pair<int, int>>>,
                 greater<pair<long long, pair<int, int>>>>
      pq;
  d[s] = 0;
  pq.push({d[s], {s, 0}});
  while (!pq.empty()) {
    auto it = pq.top();
    pq.pop();
    long long ud = it.first, u = it.second.first, who = it.second.second;
    if (d[u] < ud) continue;
    for (auto& pi : g[u]) {
      int v = pi.first;
      long long cost = pi.second;
      if (d[v] > d[u] + cost) {
        d[v] = d[u] + cost;
        int dot;
        if (vis[v])
          dot = v, which[v] = v;
        else
          dot = who, which[v] = who;
        pq.push({d[v], {v, dot}});
      }
    }
  }
}
int fa[N];
int find(int x) { return fa[x] == x ? fa[x] : fa[x] = find(fa[x]); }
void solve() {
  for (int i = 0; i <= n; ++i) fa[i] = i;
  for (auto& e : edges) {
    int u = e.u, v = e.v;
    long long w = e.w;
    e.w += d[u] + d[v];
    if (which[u])
      e.u = which[u];
    else
      e.u = u;
    if (which[v])
      e.v = which[v];
    else
      e.v = v;
  }
  long long ans = 0;
  sort(edges.begin(), edges.end(), cmp);
  for (const auto& e : edges) {
    int u = e.u, v = e.v;
    long long w = e.w;
    int fu = find(u), fv = find(v);
    if (fu != fv) {
      ans += w;
      fa[fu] = fv;
    }
  }
  cout << ans + d[1] << endl;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    g[u].push_back({v, w});
    g[v].push_back({u, w});
    edges.push_back({w, u, v});
  }
  scanf("%d", &k);
  for (int i = 1; i <= k; ++i) {
    int v;
    scanf("%d", &v);
    vis[v] = true;
    g[0].push_back({v, 0});
  }
  dij(0);
  solve();
  return 0;
}
