#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int n, m, r, INF = 1e9;
  cin >> n >> m >> r;
  vector<int> R(r);
  for(int i = 0; i < r; ++i){
    cin >> R[i];
    --R[i];
  }
  vector< vector<int> > D(n,vector<int>(n,INF));
  int a, b, c;
  for(int i = 0; i < m; ++i){
    cin >> a >> b >> c;
    --a;--b;
    D[a][b] = c;
    D[b][a] = c;
  }
  for(int k = 0; k < n; ++k){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
      }
    }
  }
  sort(R.begin(), R.end());
  int ans = INF;
  do{
    int t = 0;
    for(int i = 1; i < r; ++i) t += D[R[i-1]][R[i]];
    ans = min(ans, t);
  }while(next_permutation(R.begin(), R.end()));
  cout << ans << endl;
  return 0;
}
