#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;
const long long inf = 1e18;
int n, m, k, par[maxn], f[maxn];
long long ans, Len[maxn];
bool port[maxn];
vector<pair<int, long long> > e[maxn], e_port[maxn];
set<pair<long long, int> > q;
vector<pair<long long, pair<int, int> > > edge;
int finds(int x) {
  if (f[x] == 0) {
    return x;
  }
  return f[x] = finds(f[x]);
}
void dsu(int x, int y, long long w) {
  x = finds(x);
  y = finds(y);
  if (x != y) {
    ans += w;
    f[x] = y;
  }
  return;
}
void dij() {
  for (int i = 1; i <= n; i++) {
    if (port[i] == 1) {
      Len[i] = 0;
      par[i] = i;
      q.insert({0, i});
    } else {
      Len[i] = inf;
      par[i] = -1;
      q.insert({inf, i});
    }
  }
  while (q.size() > 0) {
    auto tmp = *q.begin();
    q.erase(q.begin());
    int v = tmp.second;
    long long w = tmp.first;
    for (auto tmp : e[v]) {
      int u = tmp.first;
      int W = tmp.second;
      if (Len[u] > w + W) {
        auto it = q.find({Len[u], u});
        if (it != q.end()) q.erase(it);
        Len[u] = w + W;
        par[u] = par[v];
        q.insert({w + W, u});
      }
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int tmp1, tmp2, tmp3;
    cin >> tmp1 >> tmp2 >> tmp3;
    e[tmp1].push_back({tmp2, tmp3});
    e[tmp2].push_back({tmp1, tmp3});
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    int tmp1;
    cin >> tmp1;
    port[tmp1] = 1;
  }
  dij();
  if (port[1] == 0) {
    ans += Len[1];
  }
  for (int i = 1; i <= n; i++) {
    for (auto tmp : e[i]) {
      int v = i;
      int u = tmp.first;
      int x = par[v];
      int y = par[u];
      int w = tmp.second;
      if (x != y) {
        e_port[x].push_back({y, Len[v] + Len[u] + w});
      }
    }
  }
  for (int v = 1; v <= n; v++) {
    for (auto tmp : e_port[v]) {
      int u = tmp.first;
      long long w = tmp.second;
      edge.push_back({w, {v, u}});
    }
  }
  sort(edge.begin(), edge.end());
  for (auto tmp : edge) {
    dsu(tmp.second.first, tmp.second.second, tmp.first);
  }
  cout << ans << endl;
  return 0;
}
