#include <bits/stdc++.h>   using namespace std;   typedef const char* cstr;   const int oo = (~0u) >> 1;   const long long int ooll = (~0ull) >> 1;   const double inf = 1e+20;   const double eps = 1e-8;   const double pi = acos(-1.0);   const int MOD = 1000000007;   template <typename type>   inline bool cmax(type& a, const type& b) {     return a < b ? a = b, true : false;   }   template <typename type>   inline bool cmin(type& a, const type& b) {     return b < a ? a = b, true : false;   }   template <typename type>   inline type sqr(const type& first) {     return first * first;   }   inline int dbcmp(const double& a, const double& b) {     return (a > b + eps) - (a < b - eps);   }   inline int sgn(const double& first) { return dbcmp(first, 0); }   template <typename type>   inline type cross(const pair<type, type>& a, const pair<type, type>& b,                     const pair<type, type>& c) {     return (b.first - a.first) * (c.second - a.second) -            (b.second - a.second) * (c.first - a.first);   }   template <typename type>   inline type dot(const pair<type, type>& a, const pair<type, type>& b,                   const pair<type, type>& c) {     return (b.first - a.first) * (c.first - a.first) +            (b.second - a.second) * (c.second - a.second);   }   template <typename type>   inline type gcd(type a, type b) {     if (b)       while ((a %= b) && (b %= a))         ;     return a + b;   }   template <typename type>   inline type lcm(type a, type b) {     return a * b / gcd(a, b);   }   template <typename type>   inline void bit_inc(vector<type>& st, int first, type inc) {     while (first < ((int)(st).size())) st[first] += inc, first |= first + 1;   }   template <typename type>   inline type bit_sum(const vector<type>& st, int first) {     type s = 0;     while (first >= 0) s += st[first], first = (first & (first + 1)) - 1;     return s;   }   template <typename type>   inline type bit_kth(const vector<type>& st, int k) {     int first = 0, second = 0, z = 0;     while ((1 << (++second)) < ((int)(st).size()))       ;     for (int i = (second - 1); i >= 0; --i) {       if ((first += 1 << i) > ((int)(st).size()) || z + st[first - 1] > k)         first -= 1 << i;       else         z += st[first - 1];     }     return first;   }   inline void make_set(vector<int>& set) {     for (int i = (0); i < (((int)(set).size())); ++i) set[i] = i;   }   inline int find_set(vector<int>& set, int first) {     int second = first, z;     while (second != set[second]) second = set[second];     while (first != set[first]) z = set[first], set[first] = second, first = z;     return second;   }   inline bool union_set(vector<int>& set, int a, int b) {     a = find_set(set, a), b = find_set(set, b);     return a != b ? set[a] = b, true : false;   }   template <typename type>   inline void merge(type& a, type& b) {     if (((int)(a).size()) < ((int)(b).size())) swap(a, b);     for (typename type::iterator it = b.begin(); it != b.end(); b.erase(it++))       a.insert(*it);   }   template <typename type>   inline void merge(priority_queue<type>& a, priority_queue<type>& b) {     if (((int)(a).size()) < ((int)(b).size())) swap(a, b);     while (((int)(b).size())) a.push(b.top()), b.pop();   }   struct Initializer {     Initializer() { ios::sync_with_stdio(false); }     ~Initializer() { cerr; }   } initializer;   int main() {     int n, m;     scanf( %d%d , &n, &m);     vector<vector<int> > adj(n);     vector<vector<int> > len(n);     for (int i = (0); i < (m); ++i) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w), --u, --v;       adj[u].push_back(v);       len[u].push_back(w);       adj[v].push_back(u);       len[v].push_back(w);     }     int k;     scanf( %d , &k);     vector<bool> isp(n);     for (int i = (0); i < (k); ++i) {       int p;       scanf( %d , &p), --p;       isp[p] = true;     }     long long int ans;     int s;     {       priority_queue<pair<long long int, int>, vector<pair<long long int, int> >,                      greater<pair<long long int, int> > >           q;       vector<long long int> d(n, ooll);       if (cmin(d[0], 0ll)) q.push(make_pair(d[0], 0));       while (((int)(q).size())) {         if (d[q.top().second] == q.top().first) {           int u = q.top().second;           for (int i = (0); i < (((int)(adj[u]).size())); ++i) {             int v = adj[u][i], l = len[u][i];             if (cmin(d[v], d[u] + l)) q.push(make_pair(d[v], v));           }           if (isp[u]) {             ans = d[u];             s = u;             break;           }         }         q.pop();       }     }     {       priority_queue<pair<long long int, int>, vector<pair<long long int, int> >,                      greater<pair<long long int, int> > >           q;       vector<long long int> d(n, ooll);       vector<int> rt(n);       for (int i = (0); i < (n); ++i)         if (isp[i])           if (cmin(d[i], 0ll)) q.push(make_pair(d[i], i)), rt[i] = i;       while (((int)(q).size())) {         if (d[q.top().second] == q.top().first) {           int u = q.top().second;           for (int i = (0); i < (((int)(adj[u]).size())); ++i) {             int v = adj[u][i], l = len[u][i];             if (cmin(d[v], d[u] + l)) q.push(make_pair(d[v], v)), rt[v] = rt[u];           }         }         q.pop();       }       vector<pair<long long int, pair<int, int> > > edges;       for (int u = (0); u < (n); ++u)         for (int i = (0); i < (((int)(adj[u]).size())); ++i) {           int v = adj[u][i], l = len[u][i];           edges.push_back(make_pair(d[u] + d[v] + l, make_pair(rt[u], rt[v])));         }       sort((edges).begin(), (edges).end());       vector<int> st(n);       make_set(st);       for (int i = (0); i < (((int)(edges).size())); ++i) {         int u = edges[i].second.first, v = edges[i].second.second;         if (union_set(st, u, v)) ans += edges[i].first;       }     }     cout << ans <<   n ;   }