#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 1e5 + 7;
int n, m, k, is[N], pp[N], par[N];
long long dis[N];
vector<pair<long long, int> > g[N];
void dij() {
  memset(dis, 127, sizeof dis);
  set<pair<long long, int> > s;
  for (int i = 1; i <= n; i++)
    if (is[i]) {
      dis[i] = 0, pp[i] = i;
      s.insert({0, i});
    }
  while (s.size()) {
    int v = s.begin()->second;
    s.erase(s.begin());
    for (auto i : g[v])
      if (dis[v] + i.second < dis[i.first]) {
        s.erase({dis[i.first], i.first});
        dis[i.first] = dis[v] + i.second;
        pp[i.first] = pp[v];
        s.insert({dis[i.first], i.first});
      }
  }
}
inline int find(int x) {
  if (par[x] == x) return x;
  return par[x] = find(par[x]);
}
inline bool merch(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return 0;
  par[x] = y;
  return true;
}
int32_t main() {
  n = in(), m = in();
  for (int i = 0; i < m; i++) {
    int x = in(), y = in(), c = in();
    g[x].push_back({y, c});
    g[y].push_back({x, c});
  }
  k = in();
  for (int i = 0; i < k; i++) is[in()] = 1;
  dij();
  for (int i = 1; i <= n; i++) par[i] = i;
  vector<pair<long long, pair<long long, int> > > e;
  for (int j = 1; j <= n; j++)
    for (auto i : g[j])
      if (pp[j] != pp[i.first])
        e.push_back(
            {dis[i.first] + 0ll + dis[j] + i.second, {pp[i.first], pp[j]}});
  sort(e.begin(), e.end());
  long long ans = 0;
  for (auto i : e)
    if (merch((int)i.second.first, i.second.second)) ans += i.first;
  cout << dis[1] + ans << endl;
}
