#include #include #include using namespace std; typedef long long lint; typedef vectorvi; typedef pairpii; typedef pairedge; #define rep(i,n)for(int i=0;i<(int)(n);++i) const int N=110000; int par[N]; int root(int x){ if(x==par[x])return x; return par[x]=root(par[x]); } void unify(int x,int y){ x=root(x),y=root(y); par[x]=y; } int main(){ rep(i,N)par[i]=i; int n,m,k;cin>>n>>m>>k; vectores; lint sum=0; rep(i,m){ int a,b,c;cin>>a>>b>>c; es.push_back(edge(c,pii(a-1,b-1))); sum+=c; } vi e(k); lint ans=0; rep(i,k){ cin>>e[i],e[i]--; ans+=es[e[i]].first; unify(es[e[i]].second.first,es[e[i]].second.second); } sort(es.begin(),es.end()); rep(i,es.size()){ lint c=es[i].first; int a=es[i].second.first; int b=es[i].second.second; if(root(a)!=root(b)){ unify(a,b); ans+=c; } } cout<