#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
struct edge {
  int from, to;
  long long w;
  bool operator<(edge other) const { return w < other.w; }
};
edge edg[100011];
vector<pair<int, long long>> g[100011];
long long dist[100011];
int origion[100011];
int n, k, m;
int portal[100011];
int f[100011];
int visited[100011];
void init() {
  int i;
  for (i = 0; i < 100011; ++i) {
    f[i] = i;
    dist[i] = INF;
    origion[i] = i;
  }
}
int find(int x) {
  if (x == f[x]) return x;
  return f[x] = find(f[x]);
}
void unionset(int x, int y) {
  x = find(x), y = find(y);
  f[x] = y;
}
void dijkstra() {
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      q;
  int i;
  for (i = 1; i <= k; ++i) {
    dist[portal[i]] = 0;
    q.push(make_pair(0, portal[i]));
  }
  while (!q.empty()) {
    auto p = q.top();
    q.pop();
    if (visited[p.second]) continue;
    dist[p.second] = p.first;
    visited[p.second] = 1;
    for (auto np : g[p.second]) {
      int nv = np.first;
      if (!visited[nv] && dist[nv] > dist[p.second] + np.second) {
        dist[nv] = dist[p.second] + np.second;
        q.push(make_pair(dist[nv], nv));
        origion[nv] = origion[p.second];
      }
    }
  }
}
long long kruskal() {
  int i;
  long long ret = 0;
  for (i = 1; i <= m; ++i) {
    if (find(edg[i].from) != find(edg[i].to)) {
      ret += edg[i].w;
      unionset(edg[i].from, edg[i].to);
    }
  }
  return ret;
}
int main() {
  int i;
  init();
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d%I64d", &edg[i].from, &edg[i].to, &edg[i].w);
    g[edg[i].from].emplace_back(edg[i].to, edg[i].w);
    g[edg[i].to].emplace_back(edg[i].from, edg[i].w);
  }
  scanf("%d", &k);
  for (i = 1; i <= k; ++i) {
    scanf("%d", &portal[i]);
  }
  dijkstra();
  for (i = 1; i <= m; ++i) {
    edg[i].w = dist[edg[i].from] + edg[i].w + dist[edg[i].to];
    edg[i].from = origion[edg[i].from];
    edg[i].to = origion[edg[i].to];
  }
  sort(edg + 1, edg + 1 + m);
  printf("%I64d\n", kruskal() + dist[1]);
  return 0;
}
