#include <bits/stdc++.h>
using namespace std;
void getint(int &v) {
  char ch, fu = 0;
  for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') fu = 1, ch = getchar();
  for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
  if (fu) v = -v;
}
const long long INF = 1e18;
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    Q;
bool black[500010], u[500010];
long long tmp[500010], ans;
pair<long long, int> d[500010];
int nedge, too[500010], nxt[500010], fa[500010], val[500010], A[500010],
    B[500010], ts, hed[500010], p[500010], n, m, k, x[500010], y[500010],
    w[500010];
void ae(int x, int y, int w) {
  nxt[++nedge] = hed[x];
  hed[x] = nedge;
  too[nedge] = y;
  val[nedge] = w;
}
void dij() {
  while (!Q.empty()) Q.pop();
  for (int i = 1; i <= n; ++i)
    if (black[i])
      d[i] = make_pair(0ll, i), Q.push(make_pair(0ll, i));
    else
      d[i] = make_pair(INF, 0);
  while (!Q.empty()) {
    pair<long long, int> tmp = Q.top();
    Q.pop();
    if (u[tmp.second]) continue;
    u[tmp.second] = 1;
    for (int i = hed[tmp.second]; i; i = nxt[i]) {
      int y = too[i];
      if (d[tmp.second].first + val[i] >= d[y].first) continue;
      d[y] = make_pair(d[tmp.second].first + val[i], d[tmp.second].second);
      Q.push(make_pair(d[y].first, y));
    }
  }
}
bool cmp(int x, int y) { return (tmp[x] < tmp[y]); }
int getf(int x) { return fa[x] == x ? x : fa[x] = getf(fa[x]); }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    getint(x[i]), getint(y[i]), getint(w[i]);
    ae(x[i], y[i], w[i]), ae(y[i], x[i], w[i]);
  }
  cin >> k;
  for (int i = 1; i <= k; ++i) {
    int x;
    getint(x);
    black[x] = 1;
  }
  dij();
  ans = d[1].first;
  for (int i = 1; i <= m; ++i) {
    tmp[++ts] = d[x[i]].first + w[i] + d[y[i]].first;
    A[ts] = d[x[i]].second;
    B[ts] = d[y[i]].second;
  }
  for (int i = 1; i <= ts; ++i) p[i] = i;
  sort(p + 1, p + ts + 1, cmp);
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 1; i <= ts; ++i) {
    int h = p[i];
    int X = getf(A[h]), Y = getf(B[h]);
    if (X != Y) fa[X] = Y, ans += tmp[h];
  }
  cout << ans << endl;
  return 0;
}
