#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * power(a * a % md, b / 2, md) % md
                      : power(a * a % md, b / 2, md) % md));
}
const int xn = 1e5 + 10;
const int xm = -20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const long long INF = 1e18 + 10;
const int mod = 1e9 + 7;
const int base = 257;
int n, m, par[xn], sz[xn], k;
long long dist[xn], ans;
pair<long long, pair<int, int> > E[xn];
vector<pair<int, long long> > adj[xn];
bool mark[xn];
set<pair<long long, int> > st;
int get_root(int v) {
  if (v == par[v]) return v;
  return par[v] = get_root(par[v]);
}
void merge(int v, int u, long long w) {
  v = get_root(v);
  u = get_root(u);
  if (v == u) return;
  ans += w;
  if (sz[v] < sz[u]) swap(v, u);
  sz[v] += sz[u];
  par[u] = v;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int v, u, w;
    cin >> v >> u >> w;
    E[i] = {w, {v, u}};
    adj[v].push_back({u, w});
    adj[u].push_back({v, w});
  }
  for (int i = 1; i <= n; ++i) dist[i] = INF, par[i] = i, sz[i] = 1;
  cin >> k;
  for (int i = 1; i <= k; ++i) {
    int v;
    cin >> v;
    dist[v] = 0;
  }
  for (int i = 1; i <= n; ++i) st.insert({dist[i], i});
  while (st.size()) {
    int v = st.begin()->second;
    st.erase(st.begin());
    mark[v] = true;
    for (pair<int, int> u : adj[v]) {
      if (mark[u.first]) continue;
      st.erase({dist[u.first], u.first});
      if (dist[v] + u.second < dist[u.first]) par[u.first] = par[v];
      dist[u.first] = min(dist[u.first], dist[v] + u.second);
      st.insert({dist[u.first], u.first});
    }
  }
  for (int i = 1; i <= m; ++i)
    E[i].first += dist[E[i].second.first] + dist[E[i].second.second];
  sort(E + 1, E + m + 1);
  for (int i = 1; i <= m; ++i)
    merge(E[i].second.first, E[i].second.second, E[i].first);
  cout << ans + dist[1] << '\n';
  return 0;
}
