#include<bits/stdc++.h>
using namespace std;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
  int n,m,r;
  cin>>n>>m>>r;
  vector<int> q(r);
  rep(i,r){
    cin>>q[i];
    --q[i];
  }
  sort(q.begin(),q.end());
  int dist[n][n];
  rep(i,n) rep(j,n){
    if(i==j)dist[i][j]=0;
    else dist[i][j]=1000000000;
  }
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    --a;--b;
    dist[a][b]=c;
    dist[b][a]=c;
  }
  rep(i,n) rep(j,n) rep(k,n) dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
  int ans=1000000000;
  while(true){
    int tmp=0;
    rep(i,r-1)tmp+=dist[q[i]][q[i+1]];
    ans=min(ans,tmp);
    if(!next_permutation(q.begin(),q.end())) break;
  }
  cout<<ans<<endl;
}
