#include <bits/stdc++.h>
using namespace std;
int n, m, k;
struct Edge {
  int t;
  long long l;
  Edge(int _t, long long _l) : t(_t), l(_l) {}
};
vector<Edge> E[100000 + 10];
void addE(int a, int b, int c) {
  E[a].push_back(Edge(b, c));
  E[b].push_back(Edge(a, c));
}
struct WE {
  int s, t;
  long long l;
  WE(int _s, int _t, long long _l) : s(_s), t(_t), l(_l) {}
};
bool operator<(WE a, WE b) { return a.l < b.l; }
int from[100000 + 10];
bool used[100000 + 10];
void Dijkstra(vector<int> root, long long dist[]) {
  fill(dist, dist + n + 1, (1ll << 60));
  memset(used, 0, sizeof used);
  for (int i = 1; i <= n; i++) from[i] = i;
  priority_queue<pair<int, int> > pque;
  for (vector<int>::iterator e = root.begin(); e != root.end(); e++) {
    dist[*e] = 0;
    pque.push(make_pair(0, (*e)));
  }
  while (!pque.empty()) {
    int u = pque.top().second;
    pque.pop();
    if (used[u]) continue;
    used[u] = true;
    for (vector<Edge>::iterator e = E[u].begin(); e != E[u].end(); e++) {
      long long nd = dist[u] + (e->l);
      if (nd < dist[e->t]) {
        dist[e->t] = nd;
        from[e->t] = from[u];
        pque.push(make_pair(-dist[e->t], e->t));
      }
    }
  }
}
int F[100000 + 10];
int fd(int a) { return (F[a] == a) ? a : (F[a] = fd(F[a])); }
void _union(int a, int b) {
  int Fa = fd(a), Fb = fd(b);
  F[Fb] = Fa;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    addE(a, b, c);
  }
  static vector<int> S, P;
  S.push_back(1);
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    P.push_back(a);
  }
  static long long distS[100000 + 10], distP[100000 + 10];
  Dijkstra(S, distS);
  Dijkstra(P, distP);
  long long ans = (1ll << 60);
  for (vector<int>::iterator e = P.begin(); e != P.end(); e++) {
    ans = min(ans, distS[*e]);
  }
  vector<WE> weightE;
  for (int i = 1; i <= n; i++) {
    for (vector<Edge>::iterator e = E[i].begin(); e != E[i].end(); ++e) {
      if (i < (e->t)) {
        weightE.push_back(
            WE(from[i], from[e->t], distP[i] + distP[e->t] + e->l));
      }
    }
  }
  sort(weightE.begin(), weightE.end());
  for (int i = 1; i <= n; i++) F[i] = i;
  for (vector<WE>::iterator e = weightE.begin(); e != weightE.end(); e++) {
    if (fd(e->s) == fd(e->t)) continue;
    ans += e->l;
    _union(fd(e->s), fd(e->t));
  }
  cout << ans << endl;
  return 0;
}
