#include typedef long long ll; const int INF = 1e9,MOD = 1e9+7,ohara = 1e6; const ll LINF = 1e18; using namespace std; #define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++) #define rrep(i,a,b) for(ll i=(a);i<(b);i++) #define rrrep(i,a,b) for(ll i=(a);i>=(b);i--) #define all(v) (v).begin(), (v).end() #define pb(q) push_back(q) #define Size(n) (n).size() #define Cout(x) cout<<(x)<>n>>m>>k; pair> p[ohara]; map hen; map out; ll henn=0; rep(i,m){ cin>>a[i]>>b[i]>>c[i]; hen[a[i]]++; hen[b[i]]++; } rep(i,k){ cin>>d; out[d-1]=1; } henn=m; rep(i,m){ if(out[i]==1)continue; p[cnt++]=make_pair(c[i],make_pair(a[i],b[i])); } sort(p,p+cnt); reverse(p,p+cnt); rep(i,cnt){ if(henn+1==n)break; ll from,to; from=p[i].second.first; to=p[i].second.second; if(hen[from]-1<=0||hen[to]-1<=0)continue; hen[from]--; hen[to]--; ans+=p[i].first; henn--; } Cout(ans); return 0; }