#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e5 + 7, MOD = 1e9 + 7, INF = 1e18 + 7, N = 5000 + 7;
pair<pair<long long, long long>, long long> edge[maxN];
long long h[maxN], par[maxN], dis[maxN], n, m, k, x, y, ans, col[maxN], w, now,
    cur;
vector<pair<long long, long long> > a[maxN];
bool spec[maxN], v[maxN];
vector<pair<pair<long long, long long>, long long> > r;
set<pair<long long, long long> > q;
bool edge_sort(pair<pair<long long, long long>, long long> a,
               pair<pair<long long, long long>, long long> b) {
  return a.second < b.second;
}
void dijkstra() {
  for (long long i = 1; i <= n; i++) {
    if (!spec[i]) dis[i] = INF;
    col[i] = i;
    q.insert(pair<long long, long long>(dis[i], i));
  }
  for (long long i = 1; i <= n; i++) {
    now = q.begin()->second;
    v[now] = true;
    q.erase(q.begin());
    for (long long j = 0; j < a[now].size(); j++) {
      cur = a[now][j].first;
      w = a[now][j].second;
      if (!v[cur] && dis[cur] > dis[now] + w) {
        q.erase(pair<long long, long long>(dis[cur], cur));
        dis[cur] = dis[now] + w;
        q.insert(pair<long long, long long>(dis[cur], cur));
        col[cur] = col[now];
      }
    }
  }
}
long long find_par(long long xx) {
  if (par[xx] != xx) par[xx] = find_par(par[xx]);
  return par[xx];
}
void merge(long long hx, long long hy) {
  if (h[hx] > h[hy]) swap(hx, hy);
  par[hx] = hy;
  h[hy] += (h[hx] == h[hy]);
}
int main() {
  cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++)
    cin >> edge[i].first.first >> edge[i].first.second >> edge[i].second,
        a[edge[i].first.first].push_back(
            pair<long long, long long>(edge[i].first.second, edge[i].second)),
        a[edge[i].first.second].push_back(
            pair<long long, long long>(edge[i].first.first, edge[i].second));
  cin >> k;
  for (long long i = 1; i <= k; i++) cin >> x, spec[x] = true;
  dijkstra();
  for (long long i = 1; i <= n; i++) par[i] = col[i];
  for (long long i = 1; i <= m; i++) {
    x = edge[i].first.first;
    y = edge[i].first.second;
    if (col[x] != col[y]) {
      edge[i].second += dis[x] + dis[y];
      r.push_back(edge[i]);
    }
  }
  sort(r.begin(), r.end(), edge_sort);
  for (long long i = 0; i < r.size(); i++) {
    x = r[i].first.first;
    y = r[i].first.second;
    if (find_par(x) != find_par(y)) {
      merge(find_par(x), find_par(y));
      ans += r[i].second;
    }
  }
  if (!spec[1]) ans += dis[1];
  return cout << ans << "\n", 0;
}
