#include using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0;i<(n);i++) const LL INF = 1000000000000000000; struct Edge{ int to; LL d;}; LL N,Q,C; vector E[3000]; int X[3000]; LL D[3000][3000]; LL P[3000][3000]; vector order[3000]; int main(){ scanf("%lld%lld%lld",&N,&Q,&C); rep(i,N-1){ int u,v; LL d; scanf("%d%d%lld",&u,&v,&d); u--; v--; E[u].push_back({v,d}); E[v].push_back({u,d}); } rep(i,Q){ scanf("%d",&X[i]); X[i]--; } rep(i,N) rep(j,N) D[i][j]=P[i][j]=-1; rep(s,N){ queue Q; D[s][s]=0; Q.push(s); while(Q.size()){ int p=Q.front(); Q.pop(); order[s].push_back(p); for(Edge e:E[p]){ if(D[s][e.to]!=-1) continue; D[s][e.to] = D[s][p] + e.d; P[s][e.to] = p; Q.push(e.to); } } } LL T[3000]; rep(i,N) T[i]=INF; T[X[0]]=0; rep(i,Q-1){ int s=X[i], t=X[i+1]; LL buf[3000]; rep(i,N) buf[i]=T[i]+C; buf[i]=T[i]; for(int p:order[s]) for(Edge e:E[p]){ buf[e.to] = min(buf[e.to],buf[p]+e.d); } rep(i,N) buf[i]+=D[i][t]; rep(i,N) buf[i]=min(buf[i],T[i]+D[s][t]); rep(i,N) T[i]=buf[i]; } printf("%lld\n",T[X[Q-1]]); return 0; }