#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v, u;
  long long w;
  edge() {}
  edge(int a, int b, long long c) : v(a), u(b), w(c) {}
  bool operator<(edge e) const { return w < e.w; }
};
const int N = 100 * 1000 + 10;
vector<int> graph[N];
vector<long long> wei[N];
edge e[N * 2];
int n, m, par[N], cnt, upd[N];
bool is[N];
long long d[N];
int root(int v) {
  if (v == par[v]) return v;
  return par[v] = root(par[v]);
}
bool merge(int v, int u) {
  v = root(v);
  u = root(u);
  if (v == u) return false;
  par[v] = u;
  return true;
}
long long mst() {
  sort(e, e + cnt);
  long long ans = 0;
  for (int i = 0; i <= n - 1; i++) par[i] = i;
  for (int i = 0; i <= cnt - 1; i++)
    if (merge(e[i].v, e[i].u)) ans += e[i].w;
  return ans;
}
void dijk() {
  set<pair<long long, int> > st;
  for (int i = 0; i <= n - 1; i++) {
    d[i] = (1000LL * 1000 * 1000 * 1000 * 1000 * 1000);
    if (is[i]) {
      d[i] = 0;
      upd[i] = i;
    }
    st.insert(pair<long long, int>(0, i));
  }
  while (!st.empty()) {
    int ind = st.begin()->second;
    st.erase(st.begin());
    for (int i = 0; i <= ((int)(graph[ind]).size()) - 1; i++) {
      int u = graph[ind][i];
      long long w = wei[ind][i] + d[ind];
      if (d[u] > w) {
        st.erase(pair<long long, int>(d[u], u));
        d[u] = w;
        upd[u] = upd[ind];
        st.insert(pair<long long, int>(d[u], u));
      }
    }
  }
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= ((int)(graph[i]).size()) - 1; j++) {
      int u = graph[i][j];
      e[cnt++] = edge(upd[i], upd[u], wei[i][j] + d[i] + d[u]);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i <= m - 1; i++) {
    int a, b;
    long long c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
    wei[a].push_back(c);
    wei[b].push_back(c);
  }
  int k;
  cin >> k;
  for (int i = 0; i <= k - 1; i++) {
    int x;
    cin >> x;
    x--;
    is[x] = true;
  }
  dijk();
  cout << mst() + d[0] << endl;
  return 0;
}
