#include <bits/stdc++.h>
using namespace std;
const long long INFLL = 9e18;
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) >= 1) {
    vector<vector<int> > es(n);
    vector<vector<long long> > esw(n + m);
    for (int i = 0; i < m; i++) {
      int a, b, w;
      scanf("%d%d%d", &a, &b, &w), a--, b--;
      es[a].push_back(b);
      esw[a].push_back(w);
      es[b].push_back(a);
      esw[b].push_back(w);
    }
    int k;
    scanf("%d", &k);
    vector<bool> isss(n, false);
    for (int i = 0; i < k; i++) {
      int x;
      scanf("%d", &x), x--, isss[x] = true;
    }
    int start0 = -1;
    long long ans0 = -1;
    {
      priority_queue<pair<long long, int> > q;
      q.push(make_pair(0LL, 0));
      vector<long long> ds(n, INFLL);
      ds[0] = 0;
      while (!q.empty()) {
        long long cd = -q.top().first;
        int v = q.top().second;
        q.pop();
        assert(ds[v] <= cd);
        if (ds[v] != cd) continue;
        if (isss[v]) {
          start0 = v;
          ans0 = ds[v];
          break;
        }
        for (int i = 0; i < ((int)(es[v]).size()); i++) {
          int b = es[v][i];
          long long nd = cd + esw[v][i];
          if (nd < ds[b]) {
            ds[b] = nd;
            q.push(make_pair(-nd, b));
          }
        }
      }
    }
    vector<long long> ds(n, INFLL);
    vector<set<int> > ks(n);
    {
      priority_queue<pair<long long, int> > q;
      for (int i = 0; i < n; i++)
        if (isss[i]) {
          ds[i] = 0;
          ks[i].insert(i);
          q.push(make_pair(0LL, i));
        }
      while (!q.empty()) {
        long long cd = -q.top().first;
        int v = q.top().second;
        q.pop();
        assert(ds[v] <= cd);
        if (ds[v] != cd) continue;
        if (((int)(ks[v]).size()) > 1) continue;
        for (int i = 0; i < ((int)(es[v]).size()); i++) {
          int b = es[v][i];
          long long nd = cd + esw[v][i];
          if (nd < ds[b]) {
            ds[b] = nd;
            ks[b] = ks[v];
            q.push(make_pair(-nd, b));
          } else if (nd == ds[b]) {
            ks[b].insert(*ks[v].begin());
          }
        }
      }
    }
    vector<vector<int> > allNear(n);
    for (int i = 0; i < n; i++)
      for (set<int>::iterator it = ks[i].begin(); it != ks[i].end(); it++)
        allNear[*it].push_back(i);
    priority_queue<pair<long long, int> > q;
    bool first = true;
    long long ans = 0;
    vector<bool> was(n, false);
    while (!q.empty() || first) {
      pair<long long, int> cadd(1, -1);
      if (first)
        cadd = make_pair(-ans0, start0);
      else {
        cadd = q.top();
        q.pop();
      }
      first = false;
      assert(cadd.second >= 0);
      int start = cadd.second;
      if (was[start]) continue;
      was[start] = true;
      ans += -cadd.first;
      for (int i = 0; i < ((int)(allNear[start]).size()); i++) {
        int v = allNear[start][i];
        assert(ks[v].count(start));
        ks[v].erase(start);
      }
      for (int i = 0; i < ((int)(allNear[start]).size()); i++) {
        int v = allNear[start][i];
        if (!ks[v].empty()) {
          q.push(make_pair(-2 * ds[v], *ks[v].begin()));
        }
        for (int i2 = 0; i2 < ((int)(es[v]).size()); i2++) {
          int b = es[v][i2];
          if (ks[b].empty()) continue;
          long long nd = ds[v] + ds[b] + esw[v][i2];
          q.push(make_pair(-nd, *ks[b].begin()));
        }
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
